diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..603032d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM mambaorg/micromamba:0.14.0 + +RUN apt-get update + +COPY environment.yml /tmp/environment.yaml + +RUN micromamba env create -f /tmp/environment.yaml && \ + micromamba clean --all --yes + +COPY ./ /home/docker/api +COPY .env /home/docker/api/.env + +RUN useradd -ms /bin/bash docker +WORKDIR /home/docker +USER docker + +ENV PATH="/opt/conda/envs/ptox/bin:$PATH" + +#CMD ["bash"] + +RUN /bin/bash -c "micromamba activate ptox" + +WORKDIR "/home/docker/api" + +#CMD [ "flask", "run" ] + +CMD ["uwsgi", "app.ini"] + diff --git a/app.ini b/app.ini new file mode 100644 index 0000000..8a1b227 --- /dev/null +++ b/app.ini @@ -0,0 +1,25 @@ +[uwsgi] +# the module itself, by referring to the wsgi.py file minus the extension, and the callable within the file, app: +module = wsgi:app + +# Enable hot reload! +py-autoreload = 1 + +# Nginx to handle actual client connections, which will then pass requests to uWSGI. +socket = /tmp/mysite.sock +# socket = :80 + + +master = false +processes = 1 +cheaper = 0 +lazy-apps = true +threads = 2 + +# giving the Nginx group ownership of the uWSGI process later on, +# so we need to make sure the group owner of the socket can read information from it and write to it. +chmod-socket = 660 + +# clean up the socket when the process stops by adding the vacuum option: +vacuum = true +die-on-term = true \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..3b3b450 --- /dev/null +++ b/environment.yml @@ -0,0 +1,18 @@ +name: ptox +channels: + - conda-forge +dependencies: + - python=3.8.1 + - psycopg2~=2.9.3 + - Flask~=2.1.1 + - python-dotenv + - graphene>=3.0 + - sqlparse>=0.3.0 + - Pygments>=2.0.1 + - flask-cors>=3.0.2 + - uwsgi==2.0.20 + + + + + diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..6d6a09c --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/bash +app="docker.test" +docker build -t ${app} . +docker run -d -p 56733:5000 \ + --name=${app} \ + -v $PWD:/app ${app} \ No newline at end of file diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..11e7de6 --- /dev/null +++ b/wsgi.py @@ -0,0 +1,4 @@ +from app import app + +if __name__ == "__main__": + app.run() \ No newline at end of file