Skip to content

Commit

Permalink
chore(docker): Fix Dockerfile by using nightly toolchain (#22)
Browse files Browse the repository at this point in the history
* Add docker build (without push) to pipeline on pr

* Move test build to check-lint-test pipeline

* Build with nightly toolchain in dockerfile

* Install nightly toolchain in dockerfile
  • Loading branch information
ckoopmann authored Dec 15, 2023
1 parent 6cd0468 commit 6b061b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/check-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,25 @@ jobs:

- name: cargo test
run: cargo +nightly test

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Extract short SHA
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV

- name: Build (without push)
uses: docker/build-push-action@v5
if: github.event_name == 'pull_request'
with:
context: .
push: false
tags: |
ultrasoundorg/payload-validator:${{ env.SHORT_SHA }}
ultrasoundorg/payload-validator:latest
cache-from: type=gha
cache-to: type=gha,mode=max

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ WORKDIR /app
RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config

COPY Cargo.toml Cargo.lock ./
RUN rustup install nightly
RUN mkdir src/
RUN echo "fn main() {}" > dummy.rs
RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml
RUN cargo build --release
RUN cargo +nightly build --release

# Build executable.
RUN sed -i 's#dummy.rs#src/main.rs#' Cargo.toml
COPY src ./src
RUN cargo build --release
RUN cargo +nightly build --release

# Build runtime image.
FROM gcr.io/distroless/cc-debian12 AS runtime
Expand Down

0 comments on commit 6b061b2

Please sign in to comment.