-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (45 loc) · 2.12 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
FROM ubuntu:22.04
# Create a new user (not root)
RUN addgroup --system kursstatistik && adduser --system --ingroup kursstatistik kursstatistikuser
LABEL maintainer="KTH StudAdm studadm.developers@kth.se"
# Ubuntu version
RUN cat /etc/issue
# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Stockholm
RUN apt-get update
# will be needed for Ubuntu 22.04 locally to upgrade to get OpenSSL 3
RUN apt upgrade -y
RUN apt-get -y install python2 make gcc g++ python2.7 libxml2 openssl stunnel curl git gnupg
# Check OpenSSL version
RUN openssl version -a
#Curl and install nodejs 18
RUN mkdir -p /etc/apt/keyrings
RUN gpg --version
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN 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
RUN apt-get install -y nodejs
RUN node -v
# make /var/run/ directory to be used by kursstatistikuser
RUN chown -R kursstatistikuser:kursstatistik /var/run/
RUN mkdir -p /application && \
# make /application is owned by the user kursstatistikuser (not root)
chown -R kursstatistikuser:kursstatistik /application
WORKDIR /application
# Run as user kursstatistikuser (not root)
USER kursstatistikuser
COPY --chown=kursstatistikuser:kursstatistik ["package-lock.json", "package-lock.json"]
COPY --chown=kursstatistikuser:kursstatistik ["package.json", "package.json"]
RUN npm pkg delete scripts.prepare && \
npm install --omit=dev
# change premission of node_modules for unit/integration tests
RUN chown -R kursstatistikuser /application/node_modules
COPY --chown=kursstatistikuser:kursstatistik ["config", "config"]
COPY --chown=kursstatistikuser:kursstatistik ["app.js", "app.js"]
COPY --chown=kursstatistikuser:kursstatistik ["swagger.json", "swagger.json"]
COPY --chown=kursstatistikuser:kursstatistik ["server", "server"]
COPY --chown=kursstatistikuser:kursstatistik ["run.sh", "run.sh"]
RUN chmod +x ./run.sh
EXPOSE 3001
CMD ["./run.sh","node", "app.js"]