Skip to content

Commit b09e56b

Browse files
committed
update repo with ci and configs and docker builds
1 parent 01bd315 commit b09e56b

9 files changed

+947
-375
lines changed

Diff for: .dockerignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
__pycache__/
2+
*.py[cod]
3+
_pyright/
4+
.git/
5+
.github/
6+
.venv/
7+
.vscode/
8+
botw/
9+
buffer/
10+
configs/
11+
duckling/
12+
extensions/
13+
logs/
14+
schemas/
15+
.gitignore
16+
.gitmodules
17+
**/*.ipynb
18+
docker-compose.yml
19+
Dockerfile
20+
LICENSE
21+
README.md

Diff for: .github/workflows/build_and_push.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# GitHub recommends pinning actions to a commit SHA.
7+
# To get a newer version, you will need to update the SHA.
8+
# You can also reference a tag or branch, but the action may change without warning.
9+
10+
name: Create and publish a Docker image
11+
12+
on:
13+
push:
14+
branches:
15+
- main
16+
17+
concurrency:
18+
cancel-in-progress: true
19+
group: ci-${{ github.ref }}
20+
21+
env:
22+
REGISTRY: ghcr.io
23+
IMAGE_NAME: ${{ github.repository }}
24+
25+
jobs:
26+
build-and-push-image:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
packages: write
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
36+
- name: Log in to the Container registry
37+
uses: docker/login-action@master
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract metadata (tags, labels) for Docker
44+
id: meta
45+
uses: docker/metadata-action@master
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@master
51+
with:
52+
context: .
53+
push: true
54+
tags: "ghcr.io/pythonistaguild/pythonista-api:latest"
55+
labels: ${{ steps.meta.outputs.labels }}

Diff for: .github/workflows/coverage_and_lint.yml

+1-10
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,4 @@ jobs:
7272

7373
- name: Lint
7474
if: ${{ always() && steps.install-deps.outcome == 'success' }}
75-
uses: github/super-linter/slim@v4
76-
env:
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
DEFAULT_BRANCH: main
79-
VALIDATE_ALL_CODEBASE: false
80-
VALIDATE_PYTHON_BLACK: true
81-
VALIDATE_PYTHON_ISORT: true
82-
LINTER_RULES_PATH: /
83-
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
84-
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
75+
uses: chartboost/ruff-action@v1

Diff for: .github/workflows/deploy.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Create and publish a Docker image"]
6+
branches: [main]
7+
types:
8+
- completed
9+
10+
jobs:
11+
deploy:
12+
name: Deploy bot
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Remote deploy
16+
uses: appleboy/ssh-action@master
17+
with:
18+
host: ${{ secrets.SSH_HOST }}
19+
key: ${{ secrets.SSH_KEY }}
20+
port: ${{ secrets.SSH_PORT }}
21+
script: |
22+
cd ~/projects/pythonista-api/
23+
git reset --hard HEAD || true
24+
git pull origin main
25+
docker compose pull
26+
docker compose up -d --build --force-recreate
27+
username: ${{ secrets.SSH_USER }}

Diff for: Dockerfile

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
FROM python:3.11-slim
2+
3+
LABEL org.opencontainers.image.source=https://github.com/PythonistaGuild/Pythonista-API
4+
LABEL org.opencontainers.image.description="Pythonista API"
5+
LABEL org.opencontainers.image.licenses=MIT
6+
7+
ENV PYTHONUNBUFFERED=1 \
8+
# prevents python creating .pyc files
9+
PYTHONDONTWRITEBYTECODE=1 \
10+
\
11+
# pip
12+
PIP_NO_CACHE_DIR=off \
13+
PIP_DISABLE_PIP_VERSION_CHECK=on \
14+
PIP_DEFAULT_TIMEOUT=100 \
15+
\
16+
# poetry
17+
# https://python-poetry.org/docs/configuration/#using-environment-variables
18+
# make poetry install to this location
19+
POETRY_HOME="/opt/poetry" \
20+
# make poetry create the virtual environment in the project's root
21+
# it gets named `.venv`
22+
POETRY_VIRTUALENVS_IN_PROJECT=true \
23+
# do not ask any interactive question
24+
POETRY_NO_INTERACTION=1 \
25+
\
26+
# paths
27+
# this is where our requirements + virtual environment will live
28+
PYSETUP_PATH="/opt/pysetup" \
29+
VENV_PATH="/opt/pysetup/.venv"
30+
31+
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
32+
33+
RUN apt-get update \
34+
&& apt-get install --no-install-recommends -y \
35+
git \
36+
# deps for installing poetry
37+
curl \
38+
ca-certificates \
39+
# deps for building python deps
40+
build-essential \
41+
libcurl4-gnutls-dev \
42+
gnutls-dev \
43+
gnupg \
44+
libmagic-dev
45+
46+
RUN curl -sSL https://install.python-poetry.org | python -
47+
48+
# copy project requirement files here to ensure they will be cached.
49+
WORKDIR /app
50+
COPY poetry.lock pyproject.toml ./
51+
52+
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
53+
RUN poetry install --without=dev
54+
55+
COPY . /app/
56+
ENTRYPOINT poetry run python -O launcher.py

Diff for: docker-compose.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: "3"
2+
3+
services:
4+
api:
5+
container_name: pythonista-api
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
extra_hosts:
10+
- "database:host-gateway"
11+
restart: unless-stopped
12+
networks:
13+
- main
14+
volumes:
15+
- "./config.toml:/app/config.toml:ro"
16+
17+
networks:
18+
main:
19+
external: true

0 commit comments

Comments
 (0)