-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (35 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
44 lines (35 loc) · 1.13 KB
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
# Default release is 22.04
ARG TAG=22.04
# Default base image
ARG BASE_IMAGE=ubuntu
FROM ${BASE_IMAGE}:${TAG} AS 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 \
dnsutils
# 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
COPY app /app
# install all the required packages
WORKDIR /app
RUN npm install
# build react app
RUN npm run build
# fix
RUN npm audit fix || true
#
# main image start here
# use latest nginx image
FROM nginx:alpine-slim
RUN apk upgrade --no-cache && apk update --no-cache
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80