-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (38 loc) · 1.52 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
FROM node:20-bookworm as build
COPY . /src/
SHELL ["/bin/bash", "-c"]
ARG GIT_CLEAN="false"
ARG FAIL_DIRTY_BUILD="true"
ARG NPM_PROXY=""
WORKDIR /src/
RUN mkdir -p .buildoverride
RUN if [[ "${GIT_CLEAN}" == "true" ]]; then \
# first save the .buildoverride folder
mv .buildoverride /.buildoverride; \
# reset & clean
git reset --hard; \
git clean -fdx; \
# move override folder back
mv /.buildoverride .; \
fi
# git version only after a potential reset
RUN mkdir -p .buildoverride/src/lib/assets && scripts/print-build-version.sh | tee .buildoverride/src/lib/assets/version.txt
RUN if [[ "${FAIL_DIRTY_BUILD}" == "true" ]]; then \
grep -q -e "-dirty" .buildoverride/src/lib/assets/version.txt; \
[ $? -eq 0 ] && echo "Checkout is dirty, rejecting build." && exit 3 || true; \
fi
# copy buildoverride files over existing files
RUN cd .buildoverride && cp . .. -rv
# prepare npmrc and install dependencies
RUN --mount=type=secret,id=npm_proxy_token \
if [ -n "${NPM_PROXY}" ]; then npm config set registry "$NPM_PROXY"; fi && \
if [ -e /run/secrets/npm_proxy_token ]; then npm config set "$(echo "$NPM_PROXY" | sed 's/^https://'):_authToken" "$(cat /run/secrets/npm_proxy_token)"; fi && \
npm install && \
rm -f /root/.npmrc
# finally: build
RUN npm run build
## ensure build/vite-manifest.json no longer exists
RUN if [ -e build/vite-manifest.json ]; then exit 2; else exit 0; fi
#######################
FROM nginx:latest
COPY --from=build /src/build /usr/share/nginx/html