Skip to content

Commit

Permalink
fix dockerfile, set dotenv as a dev dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
lunakv committed Oct 2, 2022
1 parent 8b5fc9f commit b5c7f17
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
27 changes: 23 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
FROM python:3.10

# Configure Poetry
ENV POETRY_VERSION=1.2.1
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# Install poetry
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}

# add `poetry` to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app

CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
# Install dependencies
COPY poetry.lock pyproject.toml ./
RUN poetry install --no-interaction --no-cache --witout dev


# Run app
COPY ./app /code/app
CMD ["poetry", "run", "uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
2 changes: 1 addition & 1 deletion app/database/db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy.orm import sessionmaker

SQLALCHEMY_DATABASE_URL = f'postgresql+psycopg2://{os.environ["DB_USER"]}:{os.environ["DB_PASS"]}@{os.environ["DB_HOST"]}/{os.environ["DB_DATABASE"]}'

Expand Down
17 changes: 10 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ services:
build: .
ports:
- "8000:80"
environment:
# overrides for values set in .env
ADMIN_KEY: "super-secret-value"
DB_USER: server
DB_PASS: password
DB_HOST: db
DB_DATABASE: academy_ruins
env_file:
# dotenv isn't run in production
- .env
# environment:
# # overrides for values set in .env, if required
# ADMIN_KEY: "super-secret-value"
# DB_USER: server
# DB_PASS: password
# DB_HOST: db
# DB_DATABASE: academy_ruins
volumes:
- ./app:/code/app:rw
- ./generated:/code/app/resources/generated:rw
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"
packages = [{include = "academyruins_api"}]

[tool.poetry.dependencies]
python = "^3.10"
fastapi = {extras = ["all"], version = "^0.85.0"}
logging = "^0.4.9.6"
APScheduler = "^3.9.1"
boto3 = "^1.24.84"
python-dotenv = "^0.21.0"
pydantic = "^1.10.2"
requests = "^2.28.1"
SQLAlchemy = "^1.4.41"
Expand All @@ -25,6 +23,9 @@ beautifulsoup4 = "^4.11.1"
thefuzz = {extras = ["speedup"], version = "^0.19.0"}


[tool.poetry.group.dev.dependencies]
python-dotenv = "^0.21.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit b5c7f17

Please sign in to comment.