-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile-dev
62 lines (44 loc) · 1.39 KB
/
Dockerfile-dev
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# ===============================================
FROM helsinkitest/node:14-slim as staticbuilder
# ===============================================
# Offical image has npm log verbosity as info. More info - https://github.com/nodejs/docker-node#verbosity
ENV NPM_CONFIG_LOGLEVEL warn
# set our node environment, either development or production
# defaults to production, compose overrides this to development on build and run
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
# Yarn
ENV YARN_VERSION 1.19.1
RUN yarn policies set-version $YARN_VERSION
USER root
RUN apt-install.sh build-essential
# Use non-root user
USER appuser
# Install dependencies
COPY --chown=appuser:appuser package.json yarn.lock /app/
RUN yarn && yarn cache clean --force
USER root
RUN apt-cleanup.sh build-essential
# Copy all files
COPY --chown=appuser:appuser . .
# Build application
RUN yarn build
# =============================
FROM nginx:1.19 as production
# =============================
# Copy static build
COPY --from=staticbuilder --chown=nginx:nginx /app/build /usr/share/nginx/html
# Copy nginx config
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
# Env-script and .env file
WORKDIR /usr/share/nginx/html
# COPY ./scripts/env.sh .
COPY .env .
# Add bash
RUN apt-get update
RUN apt-get install bash
# Make script executable
# RUN chmod +x env.sh
USER nginx
CMD ["/bin/bash", "-c", "nginx -g \"daemon off;\""]
EXPOSE 8000