-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Containerfile and GitHub workflow (#5)
* Add basic Containerfile * Add basic GitHub workflow to check that code builds successfully
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Build code | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: gvltctl | ||
containerfiles: ./Containerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Use the official Rust image as the build environment | ||
FROM rust:1.82-bullseye as builder | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
protobuf-compiler curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -sSL "https://github.com/bufbuild/buf/releases/download/v1.0.0/buf-Linux-x86_64" -o /usr/local/bin/buf | ||
RUN chmod +x /usr/local/bin/buf | ||
|
||
RUN USER=root cargo new --bin /gvltctl | ||
|
||
WORKDIR /gvltctl | ||
|
||
COPY Cargo.toml . | ||
COPY Cargo.lock . | ||
|
||
# pre-build dependencies | ||
RUN cargo build --release | ||
|
||
# Copy the source code and build script | ||
COPY src ./src | ||
COPY build.rs . | ||
|
||
# Build the project | ||
RUN cargo build --release && cp target/release/gvltctl /gvltctl-bin | ||
|
||
# Use a minimal base image for the final stage | ||
FROM debian:bullseye-slim | ||
|
||
# Install necessary dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
libssl1.1 \ | ||
ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the compiled binary from the builder stage | ||
COPY --from=builder /gvltctl-bin /usr/local/bin/gvltctl | ||
|
||
# Set the entrypoint | ||
ENTRYPOINT ["/usr/local/bin/gvltctl"] |