Skip to content

Commit

Permalink
🔀 Merge pull request #130 from JuniorJPDJ/master
Browse files Browse the repository at this point in the history
feat(ci,Dockerfile,deps): add caching of build directories, add renovatebot config, pin dockerfile OS packages, update deps
  • Loading branch information
jh0ker authored Aug 22, 2024
2 parents f89559c + bbbc4df commit 75a2395
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 101 deletions.
62 changes: 52 additions & 10 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Docker build

on:
schedule:
- cron: '25 15 * * *'
push:
branches:
- master
Expand All @@ -24,22 +22,22 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
Expand All @@ -48,15 +46,59 @@ jobs:
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Setup buildx mount cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
home-cache-386
home-cache-amd64
home-cache-armv6
home-cache-armv7
home-cache-arm64
home-cargo-386
home-cargo-amd64
home-cargo-armv6
home-cargo-armv7
home-cargo-arm64
key: buildx-mount-cache-${{ github.sha }}
restore-keys: |
buildx-mount-cache-
- name: Inject buildx mount cache into docker
uses: reproducible-containers/buildkit-cache-dance@5b6db76d1da5c8b307d5d2e0706d266521b710de # v3.1.2
with:
cache-map: |
{
"home-cache-386": {
"target": "/root/.cache",
"id": "home-cache-linux/386"
},
"home-cache-amd64": {
"target": "/root/.cache",
"id": "home-cache-linux/amd64"
},
"home-cache-armv6": {
"target": "/root/.cache",
"id": "home-cache-linux/arm/v6"
},
"home-cache-armv7": {
"target": "/root/.cache",
"id": "home-cache-linux/arm/v7"
},
"home-cache-arm64": {
"target": "/root/.cache",
"id": "home-cache-linux/arm64"
}
}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ chart/charts

# Database file
uno.sqlite3
data/

images/api_auth.json
images/sticker_config.json
Expand Down
30 changes: 20 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
FROM python:3.11-alpine
FROM python:3.11-alpine@sha256:700b4aa84090748aafb348fc042b5970abb0a73c8f1b4fcfe0f4e3c2a4a9fcca

RUN apk add --no-cache gettext
# renovate: datasource=repology depName=alpine_3_20/gettext versioning=loose
ARG GETTEXT_VERSION="0.22.5-r0"

WORKDIR /app/
COPY requirements.txt .
RUN pip install -r requirements.txt
WORKDIR /app

COPY . .
ADD requirements.txt .

RUN cd locales && find . -maxdepth 2 -type d -name 'LC_MESSAGES' -exec ash -c 'msgfmt {}/unobot.po -o {}/unobot.mo' \;
RUN --mount=type=cache,sharing=locked,target=/root/.cache,id=home-cache-$TARGETPLATFORM \

Check warning on line 10 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$TARGETPLATFORM' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
apk add --no-cache \
gettext=${GETTEXT_VERSION} \
&& \
pip install -r requirements.txt && \
chown -R nobody:nogroup /app

COPY --chown=nobody:nogroup . .

VOLUME /app/data
ENV UNO_DB /app/data/uno.sqlite3
USER nobody

ENTRYPOINT python3 ./bot.py
RUN cd locales && \
find . -maxdepth 2 -type d -name 'LC_MESSAGES' -exec ash -c 'msgfmt {}/unobot.po -o {}/unobot.mo' \;

VOLUME /app/data
ENV UNO_DB=/app/data/uno.sqlite3

ENTRYPOINT [ "python", "bot.py" ]
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ verify_ssl = true
telethon = "*"

[packages]
python-telegram-bot = "==13.11"
python-telegram-bot = "==13.15"
pony = "*"

[requires]
Expand Down
141 changes: 73 additions & 68 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://bjw-s.github.io/helm-charts
version: 3.0.0-beta4
digest: sha256:7b1303fd68b34ce69f2b6eb8a72a1e74f77636f906f2c1499234fc8f32aa4aac
generated: "2024-03-11T03:47:29.800675883+01:00"
version: 3.3.2
digest: sha256:5a0f9f06aa383b7cc3070899b879401bcd4ae48b021d0a2b7f9ba39827019e24
generated: "2024-08-18T12:14:16.193707111Z"
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords:
dependencies:
- name: common
repository: https://bjw-s.github.io/helm-charts
version: 3.0.0-beta4
version: 3.3.2
sources:
- https://github.com/jh0ker/mau_mau_bot
annotations:
Expand Down
13 changes: 6 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: "3.9"
services:
unobot:
container_name: unobot
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
maumaubot:
# build: .
image: ghcr.io/jh0ker/mau_mau_bot
restart: unless-stopped
volumes:
- ./data:/app/data
Loading

0 comments on commit 75a2395

Please sign in to comment.