From 229f7e68e4f653417a094afae7d5fa33de241815 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Tue, 9 Apr 2024 18:33:37 +1000 Subject: [PATCH] Actually fix build (for real) --- Dockerfile | 11 +++++------ compose.prod.yml | 1 - compose.yml | 3 +++ pyproject.toml | 12 +++++++++++- src/openverse_slack_reaction/__init__.py | 0 run.py => src/openverse_slack_reaction/__main__.py | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 src/openverse_slack_reaction/__init__.py rename run.py => src/openverse_slack_reaction/__main__.py (95%) diff --git a/Dockerfile b/Dockerfile index 6610864..a32d242 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -LABEL org.opencontainers.image.source https://git.sr.ht/~sara/openverse-slack-reaction - FROM python:3.12-alpine +LABEL org.opencontainers.image.source https://git.sr.ht/~sara/openverse-slack-reaction + RUN apk add --update \ curl build-base \ && rm -rf /var/cache/apk/* @@ -21,12 +21,11 @@ WORKDIR /home/appuser/app COPY pdm.lock pdm.lock COPY pyproject.toml pyproject.toml +COPY src src +COPY static static RUN pdm install --prod --frozen-lockfile -COPY src src -COPY run.py run.py - EXPOSE 54823 -CMD ["pdm", "run", "run.py"] +CMD ["pdm", "run", "openverse-slack-reaction"] diff --git a/compose.prod.yml b/compose.prod.yml index e990699..b43ce12 100644 --- a/compose.prod.yml +++ b/compose.prod.yml @@ -4,7 +4,6 @@ services: ports: - "54823:54823" volumes: - - ./:/home/appuser/app:rw,z - openverse-slack-reaction:/data env_file: - .env diff --git a/compose.yml b/compose.yml index 4e2b7ae..5d4bd5d 100644 --- a/compose.yml +++ b/compose.yml @@ -7,6 +7,9 @@ services: image: "" build: context: . + volumes: + - ./src:/home/appuser/app/src:rw,z + - ./static:/home/appuser/app/static:rw,z environment: ENVIRONMENT: local diff --git a/pyproject.toml b/pyproject.toml index fdae8ea..c6ffd3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openverse-slack-reaction" -version = "1.2.0" +version = "1.2.0a" description = "Use Openverse to find reaction images in Slack." authors = [ {name = "sarayourfriend", email = "git@sarayourfriend.pictures"}, @@ -18,6 +18,13 @@ license = {text = "GPL-3.0"} [project.urls] Homepage = "https://git.sr.ht/~sara/openverse-slack-reaction" +[project.scripts] +openverse-slack-reaction = "openverse_slack_reaction.__main__:main" + +[build-system] +requires = ["pdm-backend"] +build-backend = "pdm.backend" + [tool.pdm] [tool.pdm.dev-dependencies] dev = [ @@ -27,3 +34,6 @@ dev = [ [tool.pdm.scripts] lint-install = "pre-commit install" lint = "pre-commit run {args:--all-files}" + +[tool.pdm.build] +package-dir = "src" diff --git a/src/openverse_slack_reaction/__init__.py b/src/openverse_slack_reaction/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/run.py b/src/openverse_slack_reaction/__main__.py similarity index 95% rename from run.py rename to src/openverse_slack_reaction/__main__.py index 90f152a..f3d5922 100644 --- a/run.py +++ b/src/openverse_slack_reaction/__main__.py @@ -2,7 +2,7 @@ import uvicorn import os -if __name__ == "__main__": +def main(): is_local = os.getenv("ENVIRONMENT") == "local" port: int = int(os.getenv("PORT", "54823")) -- 2.45.2