forked from openfoodfacts/openfoodfacts-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.frontend
41 lines (38 loc) · 1.65 KB
/
Dockerfile.frontend
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
# syntax = docker/dockerfile:1.2
# Base user uid / gid keep 1000 on prod, align with your user on dev
ARG USER_UID=1000
ARG USER_GID=1000
FROM node:lts AS builder
ARG USER_UID
ARG USER_GID
RUN usermod --uid $USER_UID node && \
groupmod --gid $USER_GID node && \
mkdir -p /opt/product-opener/node_modules && \
mkdir -p /opt/product-opener/html/data && \
mkdir -p /opt/product-opener/html/css/dist && \
mkdir -p /opt/product-opener/html/images/icons/dist && \
mkdir -p /opt/product-opener/html/js/dist && \
mkdir -p /opt/product-opener/html/images/products && \
chown node:node -R /opt/product-opener/
COPY --chown=node:node package*.json /opt/product-opener/
COPY --chown=node:node .snyk /opt/product-opener/
WORKDIR /opt/product-opener
USER node
RUN --mount=type=cache,id=npm-cache,target=/root/.npm npm install
ENV PATH /opt/product-opener/node_modules/.bin:$PATH
COPY --chown=node:node html /opt/product-opener/html
COPY --chown=node:node icons /opt/product-opener/icons
COPY --chown=node:node scss /opt/product-opener/scss
COPY --chown=node:node gulpfile.ts /opt/product-opener/
COPY --chown=node:node .snyk /opt/product-opener/
# https://github.com/openfoodfacts/openfoodfacts-server/pull/5544#issuecomment-914221199
RUN find . -xtype l | xargs -I {} sh -c "origin=\$(readlink {} | tr '\\\\\\\\' '/') && ln -sf \$origin {}"
RUN npm run build
FROM nginx:stable
WORKDIR /opt/product-opener
ARG USER_UID
ARG USER_GID
RUN usermod -u $USER_UID www-data && \
groupmod --gid $USER_GID www-data
COPY --from=builder /opt/product-opener/html/ /opt/product-opener/html/
COPY --from=builder /opt/product-opener/node_modules/ /opt/product-opener/node_modules/