-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from smkent/docker
Add Docker container and example docker-compose configuration
- Loading branch information
Showing
7 changed files
with
165 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gitignore |
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,65 @@ | ||
--- | ||
name: Build | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
RELEASE_PYTHON_VERSION: "3.10" | ||
RELEASE_POETRY_VERSION: "1.2" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- '*' | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Container: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: 💾 Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🔑 Log in to the container registry | ||
uses: docker/login-action@v2.1.0 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: 📡 Collect image metadata | ||
id: meta | ||
uses: docker/metadata-action@v4.1.1 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | ||
type=edge,branch=main | ||
- name: 🐍 Set up Python project with Poetry | ||
uses: ./.github/workflows/actions/python-poetry | ||
with: | ||
python_version: ${{ env.RELEASE_PYTHON_VERSION }} | ||
poetry_version: ${{ env.RELEASE_POETRY_VERSION }} | ||
|
||
- name: 🔥 Test | ||
run: poetry run poe test | ||
|
||
- name: 📦 Build and publish container image | ||
uses: docker/build-push-action@v3.2.0 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.egg-info/ | ||
*.pyc | ||
.coverage | ||
.git | ||
.pytest_cache/ | ||
.pytest_coverage.xml | ||
.pytest_results.xml | ||
|
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,16 @@ | ||
FROM python:3-alpine | ||
ENV CRON_SCHEDULE "5 2 * * *" | ||
ENV SMTPHOST= | ||
ENV SAFEWAY_ACCOUNT_USERNAME= | ||
ENV SAFEWAY_ACCOUNT_PASSWORD= | ||
ENV SAFEWAY_ACCOUNT_MAIL_FROM= | ||
ENV SAFEWAY_ACCOUNT_MAIL_TO= | ||
|
||
RUN apk add --no-cache tini | ||
COPY docker/entrypoint / | ||
|
||
COPY . /python-build | ||
RUN python3 -m pip install /python-build && rm -rf /python-build | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] | ||
CMD ["/entrypoint"] |
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,13 @@ | ||
version: "3.7" | ||
|
||
services: | ||
safeway-coupons: | ||
image: ghcr.io/smkent/safeway-coupons:latest | ||
environment: | ||
CRON_SCHEDULE: "0 2 * * *" | ||
SMTPHOST: your.smtp.host | ||
SAFEWAY_ACCOUNT_USERNAME: your.safeway.account.email@example.com | ||
SAFEWAY_ACCOUNT_PASSWORD: very_secret | ||
SAFEWAY_ACCOUNT_MAIL_FROM: your.email@example.com | ||
SAFEWAY_ACCOUNT_MAIL_TO: your.email@example.com | ||
restart: unless-stopped |
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,26 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
if [ -z "${SAFEWAY_ACCOUNT_MAIL_TO}" ] \ | ||
&& [ -n "${SAFEWAY_ACCOUNT_USERNAME}" ]; then | ||
export SAFEWAY_ACCOUNT_MAIL_TO="${SAFEWAY_ACCOUNT_USERNAME}" | ||
fi | ||
|
||
if [ -n "${SAFEWAY_ACCOUNT_MAIL_FROM}" ]; then | ||
export MAILFROM="${SAFEWAY_ACCOUNT_MAIL_FROM}" | ||
fi | ||
if [ -n "${SAFEWAY_ACCOUNT_MAIL_TO}" ]; then | ||
export MAILFROM="${SAFEWAY_ACCOUNT_MAIL_TO}" | ||
fi | ||
|
||
mkdir /etc/cron.d | ||
( | ||
echo "${CRON_SCHEDULE?} safeway-coupons >/proc/1/fd/1 2>/proc/1/fd/2" | ||
) > /var/spool/cron/crontabs/root | ||
|
||
env | grep -vie 'password' | grep -e '^SAFEWAY_' -e '^SMTPHOST=' | ||
|
||
crontab -l | ||
|
||
exec crond -f -d 8 |