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