From 4358099a9446179ab4f46e728a9200b425c00f4b Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Thu, 28 Nov 2019 20:06:28 +0100 Subject: [PATCH] add Dockerfile --- Dockerfile | 17 +++++++++++++++++ docker-compose.yml | 13 +++++++++++++ run.sh | 8 ++++---- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..1e5c2c733 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.7 + +WORKDIR /app + +# copy repo contents +COPY setup.py README.md ./ +COPY optimade ./optimade +RUN pip install -e .[mongo] +RUN pip install uvicorn + +EXPOSE 80 + +ENV MAIN main + +COPY run.sh ./ + +CMD ["/app/run.sh", "$MAIN"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..9559c1e85 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '2' + +services: + optimade-index: + restart: always + build: + context: . + dockerfile: Dockerfile + #environment: + # MAIN: main_index + ports: + - '3214:5000' + # - '3214:5001' diff --git a/run.sh b/run.sh index ed45ff7f5..35223c4ba 100755 --- a/run.sh +++ b/run.sh @@ -1,11 +1,11 @@ #!/bin/bash -if [ "$1" == "index" ] -then - MAIN="main_index" +set -ex + +if [ "${MAIN}" == "main_index" ]; then PORT=5001 else MAIN="main" PORT=5000 fi -uvicorn optimade.server.$MAIN:app --reload --port $PORT +uvicorn optimade.server.$MAIN:app --reload --host 0.0.0.0 --port $PORT