-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (43 loc) · 1.59 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
# syntax=docker/dockerfile:1
FROM node:18.17.0-alpine AS BUILDER
WORKDIR /opt/frontend
COPY . /opt/frontend/
RUN --mount=type=secret,id=login \
--mount=type=secret,id=password \
set -xe && \
apk update && \
login=$(cat /run/secrets/login) && \
password=$(cat /run/secrets/password) && \
npm install -g npm-cli-login && \
npm-cli-login -u ${login} -p ${password} -e [email protected] -r https://nexus.lanars.com/repository/npm-all && \
npm config set @leo:registry https://nexus.lanars.com/repository/npm-all/ && \
npm i -g npm@10 && \
if [ -z "${BUILD_TYPE}" ]; then \
echo 'build type not set' && \
npm install && \
npm run build; \
fi &&\
if [ "${BUILD_TYPE}" = "stage" ]; then \
echo 'build type set to stage' &&\
npm ci && \
npm run build:stage; \
fi &&\
if [ "${BUILD_TYPE}" = "prod" ]; then \
echo 'build type set to prod' &&\
npm ci --only=prod && \
npm run build:prod; \
fi
FROM nginx:mainline-alpine
COPY --from=BUILDER /opt/frontend/dist /usr/share/nginx/html
COPY ./docker/default.conf /etc/nginx/conf.d/default.conf
RUN set -xe && \
apk add --no-cache --update mc htop sudo bash tini
RUN set -xe && \
addgroup user && \
adduser -h /home/user -s /bin/bash -G user -S -D user && \
chown -R user:user /home/user/ /var/run/ /opt /var/cache/nginx && \
chmod -R 777 /tmp/ /var/log/ && \
echo 'user ALL=(ALL) NOPASSWD: /usr/bin/tee, /bin/ln, /bin/sed, /bin/bash' >> /etc/sudoers.d/user USER user
USER user
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["nginx", "-g", "daemon off;"]