From 48c95b975ac80e3792b3c477148b5f5e1323f556 Mon Sep 17 00:00:00 2001 From: Histausse Date: Wed, 24 May 2023 12:33:11 +0200 Subject: [PATCH] push docker with CI --- hooks/post_gen_project.py | 1 + .../.woodpecker.yml | 19 ++++++++++++++++--- {{ cookiecutter.project_slug }}/README.md | 10 +++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index d5a995d..c2e94cf 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -16,6 +16,7 @@ for path in REMOVE_PATHS: else: os.unlink(path) +subprocess.call(["poetry", "lock"]) subprocess.call(["git", "init"]) subprocess.call(["git", "checkout", "-b", "main"]) subprocess.call(["git", "add", "*"]) diff --git a/{{ cookiecutter.project_slug }}/.woodpecker.yml b/{{ cookiecutter.project_slug }}/.woodpecker.yml index d00a7e9..5cafcce 100644 --- a/{{ cookiecutter.project_slug }}/.woodpecker.yml +++ b/{{ cookiecutter.project_slug }}/.woodpecker.yml @@ -16,11 +16,24 @@ pipeline: pull: true commands: - nix build --experimental-features 'nix-command flakes' - - nix build --experimental-features 'nix-command flakes' .#docker + - nix build -o image_link --experimental-features 'nix-command flakes' .#docker + - cp image_link image when: matrix: - PYTHON_VERSION: {{ cookiecutter. python_min_version}} # Still not sure about how to make flake for different python version + PYTHON_VERSION: {{ cookiecutter.python_min_version}} # Still not sure about how to make flake for different python version + + push_image: + image: quay.io/podman/stable:latest + pull: true + commands: + - podman login -u {{ cookiecutter.git_user }} -p $GITEA_TOKEN {{ cookiecutter.gitea_url.removeprefix('https://') }} + - podman load < image + - podman push {{ cookiecutter.project_slug }}:latest {{ cookiecutter.gitea_url.removeprefix('https://') }}/{{ cookiecutter.git_user }}/{{ cookiecutter.project_slug }}:latest + secrets: [ gitea_token ] + when: + matrix: + PYTHON_VERSION: {{ cookiecutter.python_min_version}} # Still not sure about how to make flake for different python version matrix: PYTHON_VERSION: - - {{ cookiecutter. python_min_version}} + - {{ cookiecutter.python_min_version}} diff --git a/{{ cookiecutter.project_slug }}/README.md b/{{ cookiecutter.project_slug }}/README.md index 91f75a7..f447e57 100644 --- a/{{ cookiecutter.project_slug }}/README.md +++ b/{{ cookiecutter.project_slug }}/README.md @@ -23,6 +23,13 @@ There is a `flake.nix`, so you can clone the repo and use `nix shell` if you wan ### Docker/Podman +{% if cookiecutter.configure_ci == "True" %} +You can run this projet with docker or podman: + +``` +podman run --rm -it {{ cookiecutter.gitea_url.removeprefix('https://') }}/{{ cookiecutter.git_user }}/{{ cookiecutter.project_slug }}:latest {{ cookiecutter.project_slug }} +``` +{% else %} You can build a container image using nix. To build the image, in the repo, run: ``` @@ -34,8 +41,9 @@ You can then load the image with: ``` podman load < {{ cookiecutter.project_slug }}.img ``` +{% endif %} -(If you want to use the image, notice it uses nix and is very minimal). +Notice the image is build with nix and is very minimalist. {% if is_open_source %} ## License