Skip to content

Commit

Permalink
migrate to poetry, release to ghcr only
Browse files Browse the repository at this point in the history
  • Loading branch information
markusressel committed Mar 16, 2024
1 parent 1434faa commit d3e5d06
Show file tree
Hide file tree
Showing 9 changed files with 1,681 additions and 1,417 deletions.
49 changes: 0 additions & 49 deletions .github/workflows/dockerimage-latest.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/dockerimage-release.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Docker Image

on:
push:
branches:
- main
tags:
- "*.*.*"
pull_request:
branches: [ "main" ]

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

jobs:
dockerhub:
runs-on: ubuntu-latest

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

# this writes the tag name into GIT_TAG_NAME
- name: Get tag name
uses: little-core-labs/[email protected]

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
#with:
# install: true

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Figure out release tag
id: prep
run: |
if [ $GITHUB_REF_TYPE == "tag" ]; then
RELEASE_VERSION=${GITHUB_REF_NAME#*/}
else
RELEASE_VERSION='latest'
fi
echo ::set-output name=version::${RELEASE_VERSION}
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.prep.outputs.version }},enable=${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
# linux/arm64 doesn't currently work because cffi doesn't want to build :(
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
40 changes: 28 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
FROM python:3.11-slim-buster

ENV PYTHONUNBUFFERED=1
ENV POETRY_VERSION="1.4.0"
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV VENV_HOME=/opt/poetry
WORKDIR /app

#RUN apt-get update \
#&& apt-get -y upgrade \
#&& apt-get -y install \
# git \
# gcc \
# python3-levenshtein

COPY poetry.lock pyproject.toml ./
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install \
git \
gcc \
python3-levenshtein
&& apt-get -y install python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& python3 -m venv ${VENV_HOME} \
&& ${VENV_HOME}/bin/pip install --upgrade pip \
&& ${VENV_HOME}/bin/pip install "poetry==${POETRY_VERSION}" \
&& ${VENV_HOME}/bin/poetry check \
&& POETRY_VIRTUALENVS_CREATE=false ${VENV_HOME}/bin/poetry install --no-interaction --no-cache --only main \
&& ${VENV_HOME}/bin/pip uninstall -y poetry

WORKDIR /app
# Add Poetry to PATH
ENV PATH="${VENV_HOME}/bin:${PATH}"

COPY . .
COPY keel_telegram_bot keel_telegram_bot
COPY README.md README.md

RUN pip install --upgrade pip
RUN pip install pipenv
RUN pipenv install --system --deploy
RUN pip install .
RUN ${VENV_HOME}/bin/pip install .

CMD [ "python", "./keel_telegram_bot/main.py" ]
ENTRYPOINT [ "keel-telegram-bot" ]
24 changes: 0 additions & 24 deletions Pipfile

This file was deleted.

Loading

0 comments on commit d3e5d06

Please sign in to comment.