-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (47 loc) · 1.69 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
# Default release is 22.04
ARG TAG=22.04
# Default base image
ARG BASE_IMAGE=ubuntu
FROM ${BASE_IMAGE}:${TAG} as ubuntu_node_modules_builder
# define node major version to install
ENV NODE_MAJOR=20
# install npm requirements and nginx
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg \
nginx \
dnsutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install yarn npm nodejs
RUN 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_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
npm -g install yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY var/www/html /var/www/html
# install all the required packages
WORKDIR /var/www/html
RUN yarn install --production=true && npm i --package-lock-only && npm audit fix
#
# main image start here
#
FROM ${BASE_IMAGE}:${TAG}
# add /var/www/html with node_modules installed
COPY --from=ubuntu_node_modules_builder /var/www/html /var/www/html
# add nginx and dnsutils
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx \
dnsutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# add nginx configuration file
COPY etc/nginx/sites-available /etc/nginx/sites-available
COPY docker-entrypoint.sh /
WORKDIR /
CMD [ "./docker-entrypoint.sh" ]
EXPOSE 80