diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..88762cb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,90 @@ +# Git +.git +.gitignore +.gitattributes +README.md + + +# CI +.codeclimate.yml +.travis.yml +.taskcluster.yml + +# Docker +docker-compose.yml +Dockerfile +.docker +.dockerignore + +# Byte-compiled / optimized / DLL files +**/__pycache__/ +**/*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Virtual environment +.env +.venv/ +venv/ + +# PyCharm +.idea + +# Python mode for VIM +.ropeproject +**/.ropeproject + +# Vim swap files +**/*.swp + +# VS Code +.vscode/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..de4d947 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM python:3.12-alpine as base +WORKDIR /app/ + +ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 + +RUN apk add --update --virtual .build-deps \ + build-base \ + python3-dev \ + libpq \ + gcc \ + libffi-dev + +RUN pip install poetry +COPY pyproject.toml poetry.lock* /app/ + +RUN poetry config virtualenvs.create false +RUN poetry install --without dev --no-interaction --no-ansi + + +FROM python:3.12-alpine + +EXPOSE 8010 +WORKDIR /app/ + +ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONPATH /app:$PYTHONPATH + +RUN apk add --update --no-cache libpq + +COPY --from=base /usr/local/bin/ /usr/local/bin/ +COPY --from=base /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/ + +COPY . . + +CMD [ "sh", "./start.sh" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..39941ea --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,52 @@ +version: '3' + +services: + + chain-service: + container_name: chain-service-dev + + build: + context: . + dockerfile: ./Dockerfile + + environment: + - DATABASE_URL=mongodb://chain-service:password@chain-db:27017 + + ports: + - 8010:8010 + + develop: + watch: + - action: sync+restart + path: ./chain_service/ + target: /app/chain_service/ + + - action: rebuild + path: ./pyproject.toml + + depends_on: + - chain-db + + chain-db: + image: mongo + container_name: chain-db-dev + + ports: + - 27017:27017 + + environment: + - MONGO_INITDB_ROOT_USERNAME=chain-service + - MONGO_INITDB_ROOT_PASSWORD=password + - MONGO_INITDB_DATABASE=chain-db + + volumes: + - chain-db-dev:/data/db + + healthcheck: + test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"] + interval: 30s + timeout: 10s + retries: 5 + +volumes: + chain-db-dev: