Skip to content

Commit

Permalink
ci: build multi arch docker images using buildx (#265)
Browse files Browse the repository at this point in the history
- ignore docker login in pull requests

-fix release path

- use official action for push as well

- mv tags to build step
  • Loading branch information
kskarthik authored Oct 21, 2024
1 parent 29f14b7 commit f98ed40
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Docker CI

on:
push:
# runs on every commit
branches: ["master"]
branches:
- master
pull_request:

permissions:
contents: read
Expand All @@ -15,11 +16,29 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Build the docker image
run: docker build -t steelscheme/steel:latest .

- name: Authenticate to the Docker Hub
run: docker login -u steelscheme -p ${{ secrets.DOCKER_HUB_PWD }}
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: steelscheme
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

# disable push on merge requests
- name: Test Build
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'pull_request' }}
with:
push: false
platforms: linux/amd64,linux/arm64
tags: steelscheme/steel:latest

- name: Push the docker image
run: docker push steelscheme/steel:latest
- name: Build and push the docker image
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'pull_request' }}
with:
push: true
platforms: linux/amd64,linux/arm64
tags: steelscheme/steel:latest
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:slim as build
FROM rust:slim AS build

COPY . /steel/

Expand All @@ -16,13 +16,14 @@ RUN mkdir -p /lib/steel/
ENV STEEL_HOME="/lib/steel"

RUN cargo build --release

RUN cargo install --path crates/cargo-steel-lib

RUN cd cogs && cargo run -- install.scm

FROM rust:slim

COPY --from=build /steel/target/debug/steel /usr/local/bin
COPY --from=build /steel/target/release/steel /usr/local/bin

COPY --from=build /lib/steel /lib/

Expand Down

0 comments on commit f98ed40

Please sign in to comment.