From 7e5bfb4db30379890991e86448f1ad386275b038 Mon Sep 17 00:00:00 2001 From: A_A <21040751+Otto-AA@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:33:01 +0200 Subject: [PATCH] add Dockerfile and docker-compose.yml --- .dockerignore | 27 +++++++++++++++++++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ README.md | 6 ++++++ docker-compose.yml | 10 ++++++++++ 4 files changed, 85 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..0b1e1e7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ef0aba3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +FROM ubuntu:20.04 + +EXPOSE 8000 + +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE=1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + +# Install requirements +RUN apt-get update && \ + apt-get install -y software-properties-common && \ + rm -rf /var/lib/apt/lists/* +RUN add-apt-repository ppa:deadsnakes/ppa +RUN apt-get update && apt-get install -y \ + python3.6 python3.6-distutils python3-pip \ + libssl-dev postgresql postgresql-contrib \ + && rm -rf /var/lib/apt/lists/* + + +# Install pip requirements +COPY requirements.txt . +COPY requirements-dev.txt . +RUN python3.6 -m pip install -r requirements.txt -r requirements-dev.txt + +WORKDIR /app +COPY . /app + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers +RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app +USER appuser + +# Make initial Django migrations +RUN python3.6 manage.py migrate + +# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug +# CMD ["gunicorn", "--bind", "0.0.0.0:8000", "func_sig_registry.wsgi"] +ENTRYPOINT ["python3.6", "manage.py"] +CMD ["runserver", "--settings", "func_sig_registry.settings_dev", "0.0.0.0:8000"] diff --git a/README.md b/README.md index f99f2d0..4ce4317 100644 --- a/README.md +++ b/README.md @@ -53,3 +53,9 @@ To serve the site on a development machine, bypassing several security measures, ```bash python manage.py runserver --settings func_sig_registry.settings_dev ``` + +## Usage via docker compose + +Install docker compose (tested with v2.25.0) + +Then run `docker compose up`. This will start the server in development mode which you can view at http://localhost:8000/. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..af0cee5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.4' + +services: + ethereumfunctionsignatureregistry: + image: ethereumfunctionsignatureregistry + build: + context: . + dockerfile: ./Dockerfile + ports: + - 8000:8000