## Build image and name it 'express-template' # docker build -t express-template . ## Run container and name it 'ExpressApi'. Webpage is localhost:9000 # docker run -it --rm -dp 9000:9000 --name ExpressApi express-template ## Connect to container # docker exec -it ExpressApi bash ## Show container log # docker container logs ExpressApi ## Stop docker container # docker stop ExpressApi ## All together # docker stop ExpressApi & docker image rm -f express-template & docker build -t express-template . && docker run -it --rm -dp 9000:9000 --name ExpressApi express-template && docker exec -it ExpressApi sh # Start Dockerfile ARG VERSION=18.16.0-bullseye-slim ARG DIR=ExpressApi FROM node:${VERSION} as builder ARG DIR WORKDIR /${DIR} COPY . . RUN apt-get update && \ apt-get install -y git && \ yarn install --production && \ yarn build:prod # Run Stage FROM node:${VERSION} as runner ARG DIR WORKDIR /${DIR} COPY --from=builder /${DIR}/dist ./dist COPY --from=builder /${DIR}/node_modules ./node_modules ENV TZ="America/Guatemala" ENV HOST=0.0.0.0 ENV PORT=9000 EXPOSE 9000 ENTRYPOINT ["node", "dist/app.js"]