mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-23 22:34:20 +00:00
Dockerfile refactoring (#198)
* Dockerfile refactoring * Update docker-image.yml * Update CodeQL workflow to match Steffo99/.github * Add testing workflow using `compileall` * Use release workflow from Steffo99/.github * Slightly refactor Dockerfile * Fix merge tool doing something weird --------- Co-authored-by: Stefano Pigozzi <me@steffo.eu>
This commit is contained in:
parent
b6b3902db5
commit
8bf23d4870
6 changed files with 62 additions and 174 deletions
68
.github/workflows/analysis.yml
vendored
68
.github/workflows/analysis.yml
vendored
|
@ -1,68 +0,0 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
codeql-analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'python' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
queries: security-and-quality
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
48
.github/workflows/docker-image.yml
vendored
48
.github/workflows/docker-image.yml
vendored
|
@ -1,48 +0,0 @@
|
|||
name: "Build Docker image"
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
build-docker:
|
||||
name: "🐳 Build and publish Docker image"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: "❓ Find the release semantic version"
|
||||
id: semver
|
||||
uses: Steffo99/actions-semver@v0.3.5
|
||||
with:
|
||||
string: ${{ github.event.release.tag_name }}
|
||||
|
||||
- name: "🔨 Setup Buildx"
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: "🔑 Login to GitHub Containers"
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: RYGhub
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: "🏗 Build and push the Docker image"
|
||||
uses: docker/build-push-action@v3.2.0
|
||||
with:
|
||||
tags: >-
|
||||
ghcr.io/steffo99/greed:${{ steps.semver.outputs.precedence }},
|
||||
ghcr.io/steffo99/greed:${{ steps.semver.outputs.core }},
|
||||
ghcr.io/steffo99/greed:${{ steps.semver.outputs.pair }},
|
||||
ghcr.io/steffo99/greed:${{ steps.semver.outputs.major }},
|
||||
ghcr.io/steffo99/greed:latest
|
||||
platforms: >-
|
||||
linux/amd64
|
||||
push: true
|
15
.github/workflows/quality.yml
vendored
Normal file
15
.github/workflows/quality.yml
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
name: "Periodic quality and security analysis"
|
||||
|
||||
on:
|
||||
# Every monday at 09:48 UTC
|
||||
schedule:
|
||||
- cron: "48 9 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
codeql:
|
||||
uses: Steffo99/.github/.github/workflows/quality-python-codeql.yml@main
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
56
.github/workflows/release.yml
vendored
56
.github/workflows/release.yml
vendored
|
@ -1,52 +1,16 @@
|
|||
name: "Build Docker image"
|
||||
name: "Release new version"
|
||||
|
||||
on:
|
||||
push:
|
||||
# Creation of a new tag starting with v
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
build-docker:
|
||||
name: "🐳 Build and publish Docker image"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: "❓ Find the release semantic version"
|
||||
id: semver
|
||||
uses: Steffo99/actions-semver@v0.3.5
|
||||
with:
|
||||
string: ${{ github.ref_name }}
|
||||
|
||||
- name: "🔨 Setup Buildx"
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: "🔑 Login to GitHub Containers"
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: "🔽 Find the lowercase name of the repository"
|
||||
id: reponame
|
||||
uses: ASzc/change-string-case-action@v5
|
||||
with:
|
||||
string: ${{ github.repository }}
|
||||
|
||||
- name: "🏗 Build and push the Docker image"
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
tags: >-
|
||||
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.precedence }},
|
||||
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.core }},
|
||||
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.pair }},
|
||||
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.major }},
|
||||
ghcr.io/${{ steps.reponame.outputs.lowercase }}:latest
|
||||
push: true
|
||||
test:
|
||||
uses: ./.github/workflows/test.yml
|
||||
|
||||
ghcrio:
|
||||
uses: Steffo99/.github/.github/workflows/buildrelease-docker.yml@main
|
||||
needs:
|
||||
- test
|
||||
|
|
17
.github/workflows/test.yml
vendored
Normal file
17
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: "Test suite"
|
||||
|
||||
on:
|
||||
# Modification of a project file in the main branch
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# Pull request to the main branch modifying a project file
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
# Triggered by a new release
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
uses: Steffo99/.github/.github/workflows/test-poetry-compileall.yml@main
|
32
Dockerfile
32
Dockerfile
|
@ -1,20 +1,28 @@
|
|||
FROM python:3.10 AS labels
|
||||
LABEL maintainer="Stefano Pigozzi <me@steffo.eu>"
|
||||
LABEL description="A customizable, multilanguage Telegram shop bot"
|
||||
FROM python:3.10-alpine AS dependencies
|
||||
RUN apk add --update build-base python3-dev py-pip musl-dev
|
||||
|
||||
FROM labels AS dependencies
|
||||
COPY requirements.txt ./requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
FROM dependencies AS greed
|
||||
COPY . /usr/src/greed
|
||||
WORKDIR /usr/src/greed
|
||||
COPY ./requirements.txt ./requirements.txt
|
||||
RUN pip install --no-cache-dir --requirement requirements.txt
|
||||
|
||||
#############################################################################
|
||||
|
||||
FROM python:3.10-slim AS final
|
||||
|
||||
COPY --from=dependencies /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
||||
|
||||
WORKDIR /usr/src/greed
|
||||
COPY . /usr/src/greed
|
||||
|
||||
FROM greed AS entry
|
||||
ENTRYPOINT ["python", "-OO"]
|
||||
CMD ["core.py"]
|
||||
|
||||
FROM entry AS environment
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV CONFIG_PATH="/etc/greed/config.toml"
|
||||
ENV DB_ENGINE="sqlite:////var/lib/greed/database.sqlite"
|
||||
ENV DB_ENGINE="sqlite:////var/lib/greed/database.sqlite"
|
||||
|
||||
LABEL org.opencontainers.image.title="greed"
|
||||
LABEL org.opencontainers.image.description="A customizable, multilanguage Telegram shop bot"
|
||||
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
|
||||
LABEL org.opencontainers.image.url="https://github.com/Steffo99/greed/"
|
||||
LABEL org.opencontainers.image.authors="Stefano Pigozzi <me@steffo.eu>"
|
Loading…
Reference in a new issue