Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatically generate a Docker source #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/verify-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:
--define flakes=true
--define docker=true
--define base-image="rustlang/rust:nightly"
--define docker-registry="docker.io"
--define ci=true
--define rust-ci=true
--define release-ci=true
--define release-ci=false
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
Expand Down
9 changes: 9 additions & 0 deletions Cargo.toml → Cargo.toml.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ path = "src/main.rs"

[package.metadata.blueprint]
manager = { Evm = "HelloBlueprint" }
{%- if release-ci %}

[[package.metadata.gadget.Native.sources]]
owner = "{{gh-username}}"
Expand All @@ -50,3 +51,11 @@ binaries = [
{ arch = "Amd64", os = "Linux", name = "amd64-linux-{{project-name}}-gadget" },
{ arch = "Arm64", os = "Linux", name = "arm64-linux-{{project-name}}-gadget" },
]
{%- endif %}
{%- if docker %}

[[package.metadata.gadget.Container.sources]]
registry = "{{docker-registry}}"
image = "{{gh-username}}/{{project-name}}"
tag = "0.1.0"
{%- endif %}
11 changes: 10 additions & 1 deletion hooks/pre.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if !check_bool("flakes") {
}

if !variable::is_set("docker") {
let docker = variable::prompt("Do you want to generate a Dockerfile for your gadget?", true);
let docker = variable::prompt("Do you want to deploy your gadget with Docker?", true);
variable::set("docker", docker);
}

Expand All @@ -43,6 +43,11 @@ if check_bool("docker") {
let base_image = variable::prompt("What base image should be used?", "rustlang/rust:nightly");
variable::set("base-image", base_image);
}

if !variable::is_set("docker-registry") {
let registry = variable::prompt("What registry will you be deploying to?", "docker.io");
variable::set("docker-registry", registry);
}
} else {
file::delete("./Dockerfile");
}
Expand Down Expand Up @@ -72,4 +77,8 @@ if !check_bool("release-ci") {
file::delete("./.github/workflows/release.yml");
}

if variable::is_set("docker-registry") || check_bool("release-ci") {
print("\x1b[1m(\x1b[31m!!!\x1b[39m) A native and/or Docker source has been configured. Be sure to check Cargo.toml to ensure they are correct.")
}

file::delete("./hooks");
Loading