Skip to content

Instantly share code, notes, and snippets.

@resultakak
Created October 5, 2020 12:22
Show Gist options
  • Select an option

  • Save resultakak/c3ed25d679369555cb82ef31eb2dd490 to your computer and use it in GitHub Desktop.

Select an option

Save resultakak/c3ed25d679369555cb82ef31eb2dd490 to your computer and use it in GitHub Desktop.
hsyndockr
version: '3.1'
services:
nodejs:
build:
context: .
dockerfile: Dockerfile
image: nodejs
container_name: nodejs
restart: unless-stopped
env_file: .env
environment:
- MONGO_USERNAME=$MONGO_USERNAME
- MONGO_PASSWORD=$MONGO_PASSWORD
- MONGO_HOSTNAME=db
- MONGO_PORT=$MONGO_PORT
- MONGO_DB=$MONGO_DB
ports:
- "80:8080"
volumes:
- .:/home/node/app
- node_modules:/home/node/app/node_modules
networks:
- app-network
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
FROM node:10-alpine
LABEL author="Resul Takak"
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY package*.json ./
USER node
RUN npm install
COPY --chown=node:node . .
EXPOSE 8080
CMD [ "node", "app.js" ]
https://www.digitalocean.com/community/tutorials/containerizing-a-node-js-application-for-development-with-docker-compose
https://hub.docker.com/_/node
https://hub.docker.com/_/mongo
https://github.com/do-community/nodejs-mongo-mongoose
https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment