From a6ccad31a9ca1988e99a133743f328230cd0a8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0hsan=20Oval=C4=B1?= Date: Fri, 14 Apr 2023 11:30:26 +0300 Subject: [PATCH] add docker support --- .dockerignore | 25 +++++++++++++++++++++++++ Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bd10529 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +venv +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.git +.mypy_cache +.pytest_cache +.hypothesis +FlaskApp.wsgi +Working +README.md +datas +target \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4aaf3dc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +### STAGE 1:BUILD ### +FROM python:3.10-slim AS build +RUN apt-get update +RUN apt-get install -y --no-install-recommends \ + build-essential gcc + +WORKDIR /usr/app +RUN python -m venv /usr/app/venv +ENV PATH="/usr/app/venv/bin:$PATH" + +COPY requirements.txt . +RUN pip install -r requirements.txt +RUN pip install gunicorn + +### STAGE 2:RUN ### +FROM python:3.10-slim + +RUN groupadd -g 999 python && \ + useradd -r -u 999 -g python python + +RUN mkdir /usr/app && chown python:python /usr/app +WORKDIR /usr/app + +COPY --chown=python:python --from=build /usr/app/venv ./venv +COPY --chown=python:python . . + +USER 999 + +ENV DATA_ENV remote +ENV FLASK_ENV production +ENV ELASTIC_URL https://localhost:9200/ +ENV ELASTIC_USER ${ELASTIC_USER} +ENV ELASTIC_PASS ${ELASTIC_PASS} + +ENV PATH="/usr/app/venv/bin:$PATH" +CMD [ "gunicorn", "--bind", "0.0.0.0:5000", "wsgi" ] +EXPOSE 5000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..55d492d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: "3.9" +services: + elasticsearch: + container_name: es + image: docker.elastic.co/elasticsearch/elasticsearch:8.7.0 + environment: + - xpack.security.enabled=false + - "discovery.type=single-node" + networks: + - orpha-net + ports: + - 9200:9200 + orphadata: + container_name: api-orphadata + image: orphanet/orphadata + environment: + - ELASTIC_URL=http://es:9200 + - ELASTIC_USER=elastic + - ELASTIC_PASS=changeme + networks: + - orpha-net + depends_on: + - elasticsearch + ports: + - 5000:5000 +networks: + orpha-net: + driver: bridge \ No newline at end of file