This commit is contained in:
Robert 2024-02-22 07:37:33 +07:00
parent 6b0aac5ac2
commit 1770b43c2f
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22
3 changed files with 179 additions and 0 deletions

90
.dockerignore Normal file
View File

@ -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/

37
Dockerfile Normal file
View File

@ -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" ]

52
docker-compose.yml Normal file
View File

@ -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: