Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FROM python:3.6
- RUN mkdir /web WORKDIR /web ADD . /web/ RUN pip install -r requirements.txt
- ENV FLASK_ENV="docker" EXPOSE 5000 CMD ["python", "mongo.py"]
- version: '3'
- services:
- # Define the Flask web application
- flaskapp:
- # Build the Dockerfile that is in the web directory
- build: ./web
- # Always restart the container regardless of the exit status; try and restart the container indefinitely
- restart: always
- # Expose port 8000 to other containers (not to the host of the machine)
- expose:
- - "8000"
- # Mount the web directory within the container at /home/flask/app/web
- # volumes:
- # - ./web:/homvole/flask/app/web
- # Don't create this container until the redis and mongo containers (below) have been created
- depends_on:
- - redis
- - mongo
- # Link the redis and mongo containers together so that they can talk to one another
- links:
- - redis
- - mongo
- # Pass environment variables to the flask container (this debug level lets you see more useful information)
- environment:
- FLASK_DEBUG: 1
- # Deploy with 3 replicas in the case of failure of one of the containers (only in Docker Swarm)
- deploy:
- mode: replicated
- replicas: 3
- # Define the redis Docker container
- redis:
- # use the redis:alpine image: https://hub.docker.com/_/redis/
- image: redis:alpine
- restart: always
- deploy:
- mode: replicated
- replicas: 3
- # Define the redis NGINX forward proxy container
- # Define the mongo database
- mongo:
- image: mongo
- restart: always
- environment:
- MONGO_INITDB_ROOT_USERNAME: root
- MONGO_INITDB_ROOT_PASSWORD: root
- mongo-express:
- image: mongo-express
- restart: always
- ports:
- - 8081:8081
- environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME: root
- ME_CONFIG_MONGODB_ADMINPASSWORD: root
- # Expose port 5432 to other Docker containers
- expose:
- - "8081"
- Serving Flask app "mongo" (lazy loading)
- Environment: docker
- Debug mode: off
- Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Add Comment
Please, Sign In to add comment