Skip to content

Commit

Permalink
Add Dockerfile and publish as a package.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcisioe committed Mar 29, 2024
1 parent e548eea commit 6d7ed35
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create and publish a Docker image

on:
push:
branches: ['release']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.11-alpine AS builder

RUN apk add poetry

COPY . /build
WORKDIR /build

RUN poetry build --format wheel

FROM python:3.11-alpine

COPY --from=builder /build/dist/*.whl /root
RUN pip install /root/*.whl

CMD python -m arromba_bot
2 changes: 2 additions & 0 deletions arromba_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def main() -> None:
updater = Updater(token, persistence=get_persistence())
dispatcher = updater.dispatcher

assert dispatcher is not None

dispatcher.add_handler(CommandHandler("sub", handle_sub))
dispatcher.add_handler(CommandHandler("unsub", handle_unsub))
dispatcher.add_handler(CommandHandler("list", handle_list))
Expand Down
3 changes: 3 additions & 0 deletions arromba_bot/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import main

main()
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
[tool.poetry]
name = "arromba-bot"
version = "0.1.0"
version = "0.2.0"
description = ""
authors = ["Cauê Baasch de Souza <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
python-telegram-bot = "^13.3"

# [tool.poetry.dev-dependencies]
# pytest = "^5.2"
# black = {version = "^20.8b1", allow-prereleases = true}
# mypy = "^0.812"

[tool.poetry.scripts]
arromba-bot = "arromba_bot:main"

Expand Down

0 comments on commit 6d7ed35

Please sign in to comment.