Skip to content

Commit

Permalink
Create a docker container with kaniko
Browse files Browse the repository at this point in the history
  • Loading branch information
Fethbita committed Oct 6, 2024
1 parent fc2012f commit 60f7964
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 60f7964

Please sign in to comment.