dockerfile

master
Tudor Stanciu 2021-08-01 01:55:21 +03:00
parent 213c5e48e7
commit 1ae44b5ec4
2 changed files with 64 additions and 0 deletions

28
dockerfile Normal file
View File

@ -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"]

36
notes/docker.txt Normal file
View File

@ -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 <container_id> cdn-admin-frontend
#######################################################################################################################################################
Docker container last version: 1.0.0
#######################################################################################################################################################