From 60f79643fce6cd44b93c6281494e1d9f432755a7 Mon Sep 17 00:00:00 2001 From: Fethbita Date: Sun, 6 Oct 2024 22:04:13 +0300 Subject: [PATCH] Create a docker container with kaniko --- .github/workflows/docker-image.yml | 40 ++++++++++++++++++++++++++++++ Dockerfile | 21 ++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..56ae61f --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image + +on: + push: + branches: [ "main" ] + paths: ['Dockerfile'] + pull_request: + branches: [ "main" ] + paths: ['Dockerfile'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + container: + image: gcr.io/kaniko-project/executor:v1.22.0-debug + + steps: + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 #v4.2.0 + + - if: github.ref_name == github.event.repository.default_branch + run: | + # Tag with latest + /kaniko/executor \ + --context ${GITHUB_WORKSPACE} \ + --dockerfile ${GITHUB_WORKSPACE}/Dockerfile \ + --destination $IMAGE:latest \ + --destination $IMAGE:$GITHUB_SHA \ + --cache + + - if: github.ref_name != github.event.repository.default_branch + run: | + /kaniko/executor \ + --context ${GITHUB_WORKSPACE} \ + --dockerfile ${GITHUB_WORKSPACE}/Dockerfile \ + --destination $IMAGE:$GITHUB_SHA \ + --cache diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..503e273 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Base image with Rust and Alpine +FROM rust:1.81-alpine3.20 AS builder + +# Install system dependencies and tools needed for Rust and your project +RUN apk update && \ + apk add --no-cache \ + # For pcsc dependency + pcsc-lite-dev \ + # For tracing-attributes dependency (needs crti.o) + musl-dev \ + # For OpenSSL dependency + pkgconf \ + openssl-dev \ + gcc \ + make \ + perl-dev \ + # For cargo-msrv + openssl-libs-static && \ + # Install cargo-audit and cargo-msrv + cargo install --version 0.20.1 cargo-audit && \ + cargo install --version 0.15.1 cargo-msrv