forked from datalens-tech/datalens-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (49 loc) · 1.95 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
65
FROM ubuntu:20.04
# timezone setting
ENV TZ="Etc/UTC"
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
# add node.js repository
RUN apt-get update && \
apt-get install -y ca-certificates curl gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && \
apt-get -y install nginx supervisor nodejs
# cleanup tmp and defaults
RUN rm -rf /etc/nginx/sites-enabled/default /var/lib/apt/lists/*
ARG app_version
ARG CERT
ARG USER=app
ENV APP_BUILDER_CDN=false
ENV UI_CORE_CDN=false
ENV TMPDIR=/tmp
ENV APP_VERSION=$app_version
ENV NODE_ENV=production
RUN useradd -ms /bin/bash --uid 1000 ${USER}
WORKDIR /opt/app
COPY deploy/nginx /etc/nginx
COPY deploy/supervisor /etc/supervisor/conf.d
COPY . .
# prepare rootless permissions for supervisor and nginx
RUN chown -R ${USER} /var/log/supervisor/ && \
mkdir /var/run/supervisor && \
chown -R ${USER} /var/run/supervisor && \
mkdir -p /var/cache/nginx && chown -R ${USER} /var/cache/nginx && \
mkdir -p /var/log/nginx && chown -R ${USER} /var/log/nginx && \
mkdir -p /var/lib/nginx && chown -R ${USER} /var/lib/nginx && \
touch /run/nginx.pid && chown -R ${USER} /run/nginx.pid
# build app
RUN npm ci -q --no-progress --include=dev --also=dev
RUN npm run build
RUN npm prune --production
RUN rm -rf assets deploy src /tmp/* /root/.npm
RUN chown -R ${USER} /opt/app/dist/run
# adding certificate
RUN echo $CERT > /usr/local/share/ca-certificates/cert.pem
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/cert.pem
RUN update-ca-certificates
USER app
EXPOSE 8080
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]