From b4ac02c0bf2bee425bf31ed191737a2b513361b8 Mon Sep 17 00:00:00 2001 From: MarcZierle Date: Sun, 30 Oct 2022 13:04:57 +0100 Subject: [PATCH] create docker files --- .dockerignore | 2 ++ Dockerfile | 33 +++++++++++++++++++++++++++++++++ docker-compose.yml | 7 +++++++ 3 files changed, 42 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5166196 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +**/node_modules +dist/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5c5903c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM node:19.0.0-alpine3.16 AS builder + +# create user, group and home directory +RUN mkdir -p /home/app +RUN addgroup -S app && adduser -S app -G app +WORKDIR /home/app + +# install GCC +RUN apk add build-base + +# install Python +ENV PYTHONUNBUFFERED=1 +RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python +RUN python3 -m ensurepip +RUN pip3 install --no-cache --upgrade pip setuptools + +USER app + +# install dependencies +COPY package.json . +COPY package-lock.json . +RUN npm install + +# build app +COPY . . +RUN npm run build + +FROM nginx:1.23.2-alpine AS runner + +RUN addgroup -S www && adduser -S www -G www + +# copy build files +COPY --from=builder /home/app/dist /usr/share/nginx/html diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a3c4f9e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3' +services: + app: + build: . + restart: always + ports: + - "80:80"