c a
This commit is contained in:
parent
f9743f8a84
commit
125eade964
3 changed files with 65 additions and 6 deletions
22
.forgejo/workflows/build.yaml
Normal file
22
.forgejo/workflows/build.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
build-bot:
|
||||
runs-on: nix
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.m3.fyi
|
||||
username: ${{ vars.FORGEJO_USER }}
|
||||
password: ${{ secrets.FORGEJO_TOKEN }}
|
||||
- name: Setup Docker
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build and push container
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: src/bot/
|
||||
file: ./src/bot/Dockerfile
|
||||
push: true
|
||||
tags: git.m3.fyi/metrik/vc-stats-bot:${{gitea.sha}},git.m3.fyi/metrik/vc-stats-bot:latest
|
||||
30
src/bot/Dockerfile
Normal file
30
src/bot/Dockerfile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
||||
|
||||
# Enable bytecode compilation
|
||||
ENV UV_COMPILE_BYTECODE=1
|
||||
|
||||
# Copy from the cache instead of linking since it's a mounted volume
|
||||
ENV UV_LINK_MODE=copy
|
||||
# Install the project's dependencies using the lockfile and settings
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=bind,source=uv.lock,target=uv.lock \
|
||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||
uv sync --frozen --no-install-project --no-dev
|
||||
# Then, add the rest of the project source code and install it
|
||||
# Installing separately from its dependencies allows optimal layer caching
|
||||
RUN mkdir app
|
||||
ADD bot.py app/
|
||||
ADD pyproject.toml app/
|
||||
ADD uv.lock app/
|
||||
WORKDIR /app
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --frozen --no-dev
|
||||
# Place executables in the environment at the front of the path
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
# Reset the entrypoint, don't invoke `uv`
|
||||
ENTRYPOINT []
|
||||
|
||||
CMD ["python3","bot.py"]
|
||||
|
||||
|
|
@ -2,15 +2,22 @@
|
|||
|
||||
{
|
||||
dotenv.enable = true;
|
||||
packages = [pkgs.docker];
|
||||
# https://devenv.sh/languages/
|
||||
languages.python.enable = true;
|
||||
languages.python.venv.enable = true;
|
||||
languages.python.uv.enable = true;
|
||||
languages.python.uv.sync.enable = true;
|
||||
|
||||
processes.bot.exec = "uv run bot.py";
|
||||
containers."bot".name = "vc-stats-bot";
|
||||
containers."bot".startupCommand = config.processes.bot.exec;
|
||||
containers."bot".registry = "docker://git.m3.fyi/metrik/";
|
||||
containers."bot".enableLayerDeduplication = true;
|
||||
|
||||
tasks."vc-stats-bot:build" = {
|
||||
exec = ''
|
||||
docker build -t git.m3.fyi/metrik/vc-stats-bot:latest .
|
||||
'';
|
||||
};
|
||||
|
||||
tasks."vc-stats-bot:publish" = {
|
||||
exec = ''
|
||||
docker push git.m3.fyi/metrik/vc-stats-bot:latest
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue