Hello I want to containarize my flask app and my mongo annd connect them. I have already containerize the flask app. my current code:
Dockerfile for flask container
FROM python:3.8-buster
WORKDIR /ergasiav3
ADD . /ergasiav3
RUN pip install -r requirements.txt
CMD ["python","app.py"]
I have a db.py with the connection to the mongoDB, here is the code:
from flask_pymongo import pymongo
CONNECTION_STRING = "mongodb+srv://admin:[email protected]/InfoCinemas?retryWrites=true&w=majority"
client = pymongo.MongoClient(CONNECTION_STRING)
db = client.get_database('InfoCinemas')
Users = pymongo.collection.Collection(db, 'Users')
Movies = pymongo.collection.Collection(db, 'Movies')
I also created this docker-compose.yml which seems to work but I dont know how to get the mongo as an image too.
version: '3'
services:
infocinemas:
build: .
volumes:
- ./ergasiav3
ports:
- 5000:5000
Do I need to make a second Dockerfile or do I just make the docker-compose.yml for the conterization of mongoDB?
Thank you in advance!
You don't need a separate mongo container, your data is in atlas.