diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5ceb386 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +venv diff --git a/README.md b/README.md index 8fec474..665f0e2 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,24 @@ Responsible for building new subscribie sites. - Each site runs as a uwsgi 'vassal' which allows new sites to come online without having to restart the web server +# Local development using `podman-compose` + +1. [Install `podman`](https://podman.io/getting-started/installation) +2. Install `podman-compose`: + ``` + python3 -m venv venv; + . venv/bin/activate + pip install podman-compose + ``` + +Start `subscribie-deployer` & `subscribie-server` + +``` +./run.sh +``` + +`subscribie-server` is responsible for hosting shops. + ## Configuration #### Create virtual env & install requirements: diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..91942b2 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,18 @@ +services: + subscribie-deployer: + image: subscribie/deployer + build: + context: ./src/subscribie-deployer + ports: + - "5001:5001" + # https://github.com/compose-spec/compose-spec/blob/master/spec.md#volumes + volumes: + - type: bind + source: ./src/subscribie-deployer + target: /usr/src/app + subscribie-server: + image: subscribie/subscribie-server + build: + context: ./src/subscribie-server + ports: + - "8080:80" diff --git a/run.sh b/run.sh index a85f89c..bf09144 100755 --- a/run.sh +++ b/run.sh @@ -1 +1,6 @@ -uvicorn --reload main:app --host 0.0.0.0 --port 5001 +#!/bin/bash + +set -euxo pipefail + +podman-compose up --build --force-recreate +#docker-compose -f compose.yaml up --build --force-recreate diff --git a/src/subscribie-deployer/Dockerfile b/src/subscribie-deployer/Dockerfile new file mode 100644 index 0000000..5d487e1 --- /dev/null +++ b/src/subscribie-deployer/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.10.7 +ENV PYTHONUNBUFFERED=1 + +WORKDIR /usr/src/app +COPY . . +RUN pip install -r requirements.txt + +CMD uvicorn --reload main:app --host 0.0.0.0 --port 5001 diff --git a/app.skel b/src/subscribie-deployer/app.skel similarity index 100% rename from app.skel rename to src/subscribie-deployer/app.skel diff --git a/main.py b/src/subscribie-deployer/main.py similarity index 100% rename from main.py rename to src/subscribie-deployer/main.py diff --git a/requirements.txt b/src/subscribie-deployer/requirements.txt similarity index 100% rename from requirements.txt rename to src/subscribie-deployer/requirements.txt diff --git a/src/subscribie-server/Dockerfile b/src/subscribie-server/Dockerfile new file mode 100644 index 0000000..ef6bbc9 --- /dev/null +++ b/src/subscribie-server/Dockerfile @@ -0,0 +1,15 @@ +FROM httpd + +WORKDIR /usr/src/app + +COPY . . + +RUN apt-get update && apt-get install -y python3 python3-pip + +RUN pip install -r requirements.txt + +# Enable httpd mod_proxy_uwsgi +RUN sed -i \ + -e 's/^#\(LoadModule .*mod_proxy_uwsgi.so\)/\1/' \ + conf/httpd.conf + diff --git a/src/subscribie-server/requirements.txt b/src/subscribie-server/requirements.txt new file mode 100644 index 0000000..4b47465 --- /dev/null +++ b/src/subscribie-server/requirements.txt @@ -0,0 +1 @@ +uWSGI==2.0.20