-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
50 lines (43 loc) · 1.61 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
FROM node:14-alpine as build
ENV TERM=dumb \
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
# Create a subuser so that NPM doesn't whine about running as root
RUN adduser -D -H -h /usr/src/app web && \
mkdir -p /usr/src/app && \
chown web:web /usr/src/app && \
# Install dependencies
apk add --no-cache \
ca-certificates wget \
tar bash curl perl-utils \
gcc musl-dev make m4 \
python g++ libev libev-dev linux-headers \
git patch ncurses jq && \
# esy is dynamically linked to glibc, not compiled locally. Oh well.
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk && \
apk add --no-cache glibc-2.28-r0.apk && \
npm cache verify && \
# --unsafe-perm because we want to install esy globally as root
npm install -g --unsafe-perm esy
# Use the new user for the build
WORKDIR /usr/src/app
USER web
COPY --chown=web:web ./ ./
# Build backend
RUN cd chatwheel_backend && \
rm -rf _esy && \
esy && \
jq '.buildDirs.lib.flags = ["-ccopt", "-static"]' package.json > package.json.new && \
mv package.json.new package.json && \
SHELL=sh esy && \
cp _esy/default/build/default/lib/chatwheel_backend.exe /usr/src/app && \
cp -r priv /usr/src/app
# Build frontend
RUN cd chatwheel_frontend && \
rm -rf _esy && \
SHELL=sh esy && \
rm -rf node_modules && \
npm install && \
npm run webpack:production && \
cp -r build /usr/src/app/assets
ENTRYPOINT ["/usr/src/app/chatwheel_backend.exe"]