-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
48 lines (39 loc) · 1.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Build Image
FROM node:20 AS build
WORKDIR /app
# defaultをdevelopmentにし,引数でproductionにも切り替えられるようにする
ARG BUILD_ENV=development
COPY . .
# npm startは.env.developmentが優先されるがnpm run buildでは.env.productoinが優先されるので注意。
RUN <<EOF
npm install
if [ "$BUILD_ENV" = "development" ]; then
echo "build mode = development"
npm run build-dev
elif [ "$BUILD_ENV" = "staging" ]; then
echo "build mode = staging"
npm run build-stg
elif [ "$BUILD_ENV" = "productoin" ]; then
echo "build mode = production"
npm run build
else
echo "build mode = unknown"
exit 1
fi
rm -rf node_modules/.cache
EOF
# Product Image
FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nginx:latest-al23 AS deploy
# Change owner to allow non-root users to start the service
USER root
RUN <<EOF
mkdir -p /var/log/nginx
chown -R nginx:nginx /var/log/nginx
touch /run/nginx.pid
chown -R nginx:nginx /run/nginx.pid
EOF
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 8080
USER nginx
CMD ["nginx", "-g", "daemon off;"]