-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
55 lines (38 loc) · 1.28 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
FROM node:18.7-buster
WORKDIR /usr/app
ARG UID=1000
ARG GID=1000
ARG DEFAULT_DEPTH=NA
ENV DEFAULT_DEPTH=${DEFAULT_DEPTH}
USER root
# create user if ARG doesn't exist
# we do this in two steps to avoid the || && gotcha
RUN id -u $UID || groupadd -f -g $GID tmc-user
RUN id -u $UID || useradd --create-home --shell /bin/bash -g $GID -u $UID tmc-user
# first four are for canvas dep
RUN apt-get update && apt-get install -y \
libpixman-1-dev \
libcairo2-dev \
libpangocairo-1.0-0 \
libpango1.0-dev
#recreate local structure so modules can be shared during build
COPY ./react ./react
COPY ./node ./node
# COPY --chown switch does not seem to work with variables in older versions of docker
RUN chown -R $UID:$GID /usr/app
USER $UID
WORKDIR /usr/app/react
# build react app, copy assets into static directory so node can serve
RUN yarn install && \
yarn run build && \
cp -a dist/* /usr/app/node/static/
WORKDIR /usr/app/node
# build base node app
RUN yarn install && yarn run build
RUN chmod -R +x dist
WORKDIR /usr/app/
RUN cp -a /usr/app/node/* /usr/app/ && \
rm -r /usr/app/node && \
# remove react directory only after node scripts (which have react modules as dependencies) have been built
rm -r /usr/app/react
ENTRYPOINT ["bash", "entrypoint.sh", "--prod"]