Skip to content

Commit

Permalink
add python container
Browse files Browse the repository at this point in the history
  • Loading branch information
bailletced committed Dec 4, 2024
1 parent 37710ef commit f0defe8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
22 changes: 21 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
container_name: openchurch_backend
build:
context: .
dockerfile: Dockerfile
dockerfile: ./docker/php/Dockerfile
volumes:
- .:/var/www/html
- ./usr/local/bin/docker-php-entrypoint:/usr/local/bin/docker-php-entrypoint
Expand All @@ -61,6 +61,26 @@ services:
environment:
SERVER_NAME: localhost api.openchurch.local admin.openchurch.local
DATABASE_URL: mysql://root:openchurch@db:3306/openchurch?serverVersion=11.5.2-MariaDB&charset=utf8mb4

python:
container_name: openchurch_python
build:
context: .
dockerfile: ./docker/python/Dockerfile
volumes:
- ./scripts:/app
- ./.env:/app/.env
entrypoint: ["sh", "/usr/local/bin/docker-python-entrypoint"]
command: ["/bin/sh"]
tty: true
stdin_open: true
networks:
- app-network
extra_hosts:
- "api.openchurch.local:host-gateway"
depends_on:
- backend

volumes:
openchurch_db_data: {}

Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions docker/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine:3.20.3

WORKDIR /app

RUN apk update && apk add --update --no-cache \
python3 \
py3-pip \
&& ln -sf python3 /usr/bin/python

COPY ./usr/local/bin/docker-python-entrypoint /usr/local/bin/
COPY .env /app/
5 changes: 2 additions & 3 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Created by venv; see https://docs.python.org/3/library/venv.html
bin
include
lib
venv
.env
*.sqlite
pyvenv.cfg
pywikibot.lwp
Expand Down
2 changes: 1 addition & 1 deletion scripts/synchro.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

load_dotenv(dotenv_path='../.env')
load_dotenv(dotenv_path='.env')
sentry_sdk.init(dsn=os.getenv('SENTRY_DSN_SYNCHRO'))

endpoint = "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
Expand Down
13 changes: 13 additions & 0 deletions usr/local/bin/docker-python-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -e

python3 -m venv ./venv

. ./venv/bin/activate

pip install -r requirements.txt

pip uninstall urllib3 -y \
&& pip install urllib3

exec "$@"

0 comments on commit f0defe8

Please sign in to comment.