-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
65 lines (43 loc) · 1.82 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM node:18 as build
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y libpango1.0-dev libgif-dev
ENV NODE_ENV development
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
ENV NODE_ENV production
COPY tsconfig.json .
ADD src/ ./src
ADD public/ ./public
RUN yarn run tsc ; exit 0
COPY rollup.config.js ./rollup.config.js
RUN yarn run rollup -c
COPY src/index.html ./public/index.html
RUN bash -c 'HASH=$(shasum public/main.js | awk "{ print $1; }" | cut -c37-40) ;\
test -n "$HASH" || (echo "Hash of public/main.js empty. Aborting."; rm public/main.js ; exit 1) ;\
echo "public/main.js → public/main.$HASH.js..." ;\
mv public/main.js public/main.$HASH.js ;\
cat public/index.html | sed "s/main.js/main.$HASH.js/g" > public/index.tmp.html ;\
mv public/index.tmp.html public/index.html'
RUN bash -c 'HASH=$(shasum public/main.css | awk "{ print $1; }" | cut -c37-40) ;\
test -n "$HASH" || (echo "Hash of public/main.css empty. Aborting."; rm public/main.css ; exit 1) ;\
echo "public/main.css → public/main.$HASH.css..." ;\
mv public/main.css public/main.$HASH.css ;\
cat public/index.html | sed "s/main.css/main.$HASH.css/g" > public/index.tmp.html ;\
mv public/index.tmp.html public/index.html'
COPY formations.txt .
RUN mkdir -p /app/public/formation
RUN node /app/server/server/images.js
#########################
FROM --platform=linux/amd64 node:18-bullseye-slim as node
ENV NODE_ENV production
USER node
WORKDIR /app
COPY --chown=node:node package.json yarn.lock ./
RUN yarn install --production --frozen-lockfile
COPY --chown=node:node --from=build /app/server /app/server
COPY --chown=node:node --from=build /app/public /app/public
COPY --chown=node:node --from=build /app/formations.txt /app/formations.txt
EXPOSE 3000
CMD ["node", "/app/server/server/server.js"]