-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,553 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
!./pyproject.toml | ||
!./config/unit.json | ||
!./src | ||
!./uv.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
ARG PYTHON_TAG=3.12 | ||
ARG UNIT_TAG=1.32.1-python${PYTHON_TAG} | ||
|
||
# SERVER # | ||
|
||
FROM unit:${UNIT_TAG} AS server_builder | ||
|
||
# copy only the parts needed for production | ||
COPY ./src/integrations ./src/integrations | ||
COPY ./src/solutions ./src/solutions | ||
COPY ./src/features ./src/features | ||
COPY ./src/server ./src/server | ||
|
||
# install dependencies and packages | ||
COPY --from=ghcr.io/astral-sh/uv:0.5.14 /uv /uvx /bin/ | ||
|
||
ENV UV_PROJECT_ENVIRONMENT="/usr/local/" | ||
|
||
RUN --mount=type=bind,source=./uv.lock,target=./uv.lock --mount=type=bind,source=./pyproject.toml,target=./pyproject.toml uv sync --python python${PYTHON_TAG} --locked --no-editable --no-python-downloads --link-mode copy --compile-bytecode --only-group server | ||
|
||
FROM server_builder AS server | ||
|
||
# allow access to home directory for asyncpg library | ||
RUN chgrp -R unit ${HOME} && chmod -R 050 ${HOME} | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get -y autoremove \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# copy configuration | ||
COPY ./config/unit.json /docker-entrypoint.d/config.json | ||
|
||
CMD ["unitd", "--no-daemon", "--log", "/dev/stdout"] | ||
|
||
# port 80 is already exposed by nginx unit image, can't change it... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
PYTHONOPTIMIZE=0 | ||
DEBUG_LOGGING=1 | ||
# Server | ||
SERVER_PORT=8080 | ||
# Postgres | ||
POSTGRES_DATABASE=postgres | ||
POSTGRES_HOST=localhost | ||
POSTGRES_PORT=5432 | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_SSLMODE=disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"listeners": { | ||
"*:80": { | ||
"pass": "routes/api" | ||
} | ||
}, | ||
"routes": { | ||
"api": [ | ||
{ | ||
"match": { | ||
"uri": "/health" | ||
}, | ||
"action": { | ||
"return": 204 | ||
} | ||
}, | ||
{ | ||
"match": { | ||
"uri": "/*" | ||
}, | ||
"action": { | ||
"pass": "applications/server" | ||
} | ||
} | ||
] | ||
}, | ||
"applications": { | ||
"server": { | ||
"type": "python", | ||
"protocol": "asgi", | ||
"path": "/", | ||
"module": "server", | ||
"callable": "app", | ||
"processes": 1, | ||
"environment": { | ||
"PYTHONOPTIMIZE": "2", | ||
"HOME": "." | ||
} | ||
} | ||
}, | ||
"access_log": { | ||
"path": "/dev/stdout", | ||
"format": "$time_local [ACCESS] $request_line -> $status" | ||
}, | ||
"settings": { | ||
"http": { | ||
"server_version": false | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
services: | ||
server: | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
links: | ||
- postgres | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
target: server | ||
ports: | ||
- ${SERVER_PORT:-8080}:80 | ||
restart: no | ||
environment: | ||
PYTHONOPTIMIZE: ${PYTHONOPTIMIZE:-2} | ||
DEBUG_LOGGING: ${DEBUG_LOGGING} | ||
POSTGRES_DATABASE: ${POSTGRES_DATABASE} | ||
POSTGRES_HOST: postgres | ||
POSTGRES_PORT: 5432 | ||
POSTGRES_USER: ${POSTGRES_USER} | ||
POSTGRES_SSLMODE: ${POSTGRES_SSLMODE:-prefer} | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
|
||
postgres: | ||
image: postgres:16.3-alpine3.20 | ||
restart: always | ||
environment: | ||
POSTGRES_USER: ${POSTGRES_USER} | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
POSTGRES_DB: ${POSTGRES_DATABASE} | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
ports: | ||
- ${POSTGRES_PORT}:5432 | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DATABASE}"] | ||
interval: 10s | ||
start_period: 10s | ||
timeout: 10s | ||
retries: 3 | ||
|
||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.