From 1ae44b5ec49d1d5f30163380399b8fe97185bfb3 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sun, 1 Aug 2021 01:55:21 +0300 Subject: [PATCH] dockerfile --- dockerfile | 28 ++++++++++++++++++++++++++++ notes/docker.txt | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 dockerfile create mode 100644 notes/docker.txt diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..38f3817 --- /dev/null +++ b/dockerfile @@ -0,0 +1,28 @@ +# build environment +FROM node:12-slim as builder +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . ./ +RUN npm run build + +# production environment +FROM node:12-slim +RUN printf '\n\n- Copy application files\n' + +ARG APP_SUBFOLDER=cdn-admin + +COPY --from=builder /app/build ./application/${APP_SUBFOLDER} +COPY --from=builder /app/build/index.html ./application/ + +#install static server +RUN npm install -g serve + +#set workdir to root +WORKDIR / + +EXPOSE 80 + +CMD ["sh", "-c", "serve -s application -p 80"] \ No newline at end of file diff --git a/notes/docker.txt b/notes/docker.txt new file mode 100644 index 0000000..1f19810 --- /dev/null +++ b/notes/docker.txt @@ -0,0 +1,36 @@ +####################################################################################################################################################### +Docker commands: +***************** + +Create image: +--from solution folder: +docker image build -t "cdn-admin-frontend:1.0.0" . + +Run image: +docker run -p 5053:80 -it cdn-admin-frontend:1.0.0 + +Push image to registry: +--tag image +docker tag cdn-admin-frontend:1.0.0 alpine-nexus:8500/cdn/cdn-admin-frontend:1.0.0 + +--login to registry +docker login --username=admin --password="***REMOVED***" alpine-nexus:8500 + +--push image +docker push alpine-nexus:8500/cdn/cdn-admin-frontend:1.0.0 + +Pull image from registry +--login to registry + +--pull image +docker pull alpine-nexus:8500/cdn/cdn-admin-frontend:1.0.0 + +Run container in prod env +docker run -d --name cdn-admin-frontend --restart=always -p 5010:80 alpine-nexus:8500/cdn/cdn-admin-frontend:1.0.0 + +Rename container +docker rename cdn-admin-frontend +####################################################################################################################################################### + +Docker container last version: 1.0.0 +####################################################################################################################################################### \ No newline at end of file