diff --git a/geoheat.Dockerfile b/geoheat.Dockerfile new file mode 100644 index 0000000..45180a9 --- /dev/null +++ b/geoheat.Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.10-slim + +USER root +RUN mkdir /app +COPY ./requirements.txt /app +WORKDIR /app +RUN pip install --no-cache-dir --upgrade -r requirements.txt +COPY ./src /app/src +WORKDIR /app/src + +ENV FLASK_APP=app.py +ENV FLASK_DEBUG=1 + +CMD ["flask", "run", "--host=0.0.0.0"] \ No newline at end of file diff --git a/mongo-tutorial.txt b/mongo-tutorial.txt new file mode 100644 index 0000000..5f8371d --- /dev/null +++ b/mongo-tutorial.txt @@ -0,0 +1,12 @@ +When creating a docker mongodb container we must implement two steps to enhance security. + +1. Authentication: we need to put some auth security when creating the docker container. Either in docker-compose or dockerfile. +What I did: In docker-compose, when adding an env file, this file needs to have 3 env variables: MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD, MONGO_INITDB_DATABASE + +2. Seeding and creating some database: after creating the container, it would be great to have some databases, collections and data so the app can use them. +What I did: Create a script file (.sh) which is going to be executed inmediately by the container after being up. +Using mongoimport command on the OS cli (container linux OS): +mongoimport --authenticationDatabase=$MONGO_INITDB_DATABASE -u=$MONGO_INITDB_ROOT_USERNAME -p=$MONGO_INITDB_ROOT_PASSWORD -d= -c= --file= +* we can add --drop to erase any old collection and --jsonArray if we have an array of documents (array of js objects/dictionaries) + +