Add playbook for building the images
Some checks failed
/ build (push) Failing after 15s

This commit is contained in:
phil 2024-10-30 02:07:05 +01:00
parent 9ca2ea638e
commit 114201d561
8 changed files with 80 additions and 26 deletions

View file

@ -58,7 +58,7 @@ jobs:
mkdir $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to container registry
- name: Log in to container registry (with another workaround)
uses: actions/podman-login@v1
with:
registry: ${{ vars.REGISTRY }}

View file

@ -27,10 +27,9 @@ jobs:
- uses: actions/checkout@v4
- name: Create venv
run: uv venv
- name: Install dependencies
run: uv sync
#- name: Install dependencies
# run: uv sync
- name: Run basic test (bootstrap)
run: pytest -s tests/basic.py
@ -39,7 +38,7 @@ jobs:
mkdir $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to container registry
- name: Log in to container registry (with another workaround)
uses: actions/podman-login@v1
with:
registry: ${{ vars.REGISTRY }}

View file

@ -1,7 +1,4 @@
FROM localhost/trixie_python
ENV PYTHONPATH $UV_PROJECT_ENVIRONMENT/lib/python3.12/site-packages
ENV PATH=/app/bin:$PATH
FROM localhost/treetrail-backend-base
RUN <<EOT
groupadd -r app

View file

@ -1,3 +1,5 @@
# Build: podman build -t treetrail-backend-base -f Containerfile.base
FROM localhost/treetrail-backend-deps
ENV PYTHONPATH $UV_PROJECT_ENVIRONMENT/lib/python3.12/site-packages
@ -5,8 +7,10 @@ ENV PYTHONPATH $UV_PROJECT_ENVIRONMENT/lib/python3.12/site-packages
COPY . /src
RUN --mount=type=cache,target=/root/.cache \
cd /src && uv sync --locked --no-dev --no-editable
#uv pip install \
# --python=$UV_PROJECT_ENVIRONMENT \
# --no-deps \
# /src
cd /src && \
uv sync --locked --no-dev --no-editable
#uv pip install \
# --python=$UV_PROJECT_ENVIRONMENT \
# --no-deps \
# /src

View file

@ -1,8 +0,0 @@
# Build: podman build -t localhost/python-ci -f Containerfile.ci
FROM localhost/trixie_python
RUN apt-get -y --no-install-recommends install nodejs git python3-pytest && \
apt-get clean && \
rm -rf /var/lib/apt/listsd/* && \
rm -rf /root/.cache

View file

@ -1,6 +1,6 @@
FROM localhost/trixie_python AS build
# Build: podman build -t treetrail-backend-deps -f Containerfile.deps
ENV PATH=/app/bin:$PATH
FROM localhost/trixie_python
COPY ./pyproject.toml ./README.md ./uv.lock /_lock/

View file

@ -6,7 +6,7 @@ WORKDIR /app
ENV PYTHONPATH $UV_PROJECT_ENVIRONMENT/lib/python3.12/site-packages
COPY --from=tiptop:5000/treetrail_backend_deps /app /app
COPY --from=tiptop:5000/treetrail_backend_deps /var/lib/treetrail/ /var/lib/treetrail
#COPY --from=tiptop:5000/treetrail_backend_deps /var/lib/treetrail/ /var/lib/treetrail
COPY ./treetrail ./pyproject.toml ./README.md ./
# Instances should override the prod.yaml file

62
build.yaml Normal file
View file

@ -0,0 +1,62 @@
- name: Build containers
hosts: localhost
gather_facts: false
vars:
force: false
force_rm: false
cache: false
repository: tiptop:5000
tasks:
#- name: Read conf
# ansible.builtin.include_vars:
# file: prod.yaml
# name: conf
- name: Using the variables
ansible.builtin.debug:
var: force_rm
- name: Build the base image, only with python dependencies
containers.podman.podman_image:
name: treetrail-backend-deps
state: build
path: "{{ playbook_dir }}"
build:
format: oci
force_rm: "{{ force_rm }}"
cache: "{{ cache }}"
file: Containerfile.deps
push: true
push_args:
dest: "{{ repository }}/treetrail-backend-deps"
- name: Build a backend base container image, with sources in /src
containers.podman.podman_image:
name: treetrail-backend-base
state: build
force: "{{ force }}"
path: "{{ playbook_dir }}"
build:
format: oci
force_rm: "{{ force_rm }}"
cache: "{{ cache }}"
file: Containerfile.base
push: true
push_args:
dest: "{{ repository }}/treetrail-backend-base"
- name: Build the prod container image
containers.podman.podman_image:
name: treetrail-backend
state: build
force: "{{ force }}"
path: "{{ playbook_dir }}"
build:
format: oci
force_rm: "{{ force_rm }}"
cache: "{{ cache }}"
file: Containerfile
push: true
push_args:
dest: "{{ repository }}/treetrail-backend"