Skip to content

Commit

Permalink
Bump Dockerfile & Build process
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed May 20, 2023
1 parent 36333da commit 9e868a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
26 changes: 25 additions & 1 deletion .github/.deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
####################################################################################################
## Base image
####################################################################################################
FROM rust:latest AS builder

RUN update-ca-certificates

WORKDIR /enstate

COPY ./Cargo.toml .
COPY ./Cargo.lock .

RUN mkdir ./src && echo 'fn main() { println!("Dummy!"); }' > ./src/main.rs

RUN cargo build --release

RUN rm -rf ./src

COPY build.rs build.rs
COPY src src
COPY .git .git

RUN cargo build --release

####################################################################################################
## Final image
####################################################################################################
Expand All @@ -6,6 +30,6 @@ FROM gcr.io/distroless/cc
WORKDIR /enstate

# Copy our build
COPY ./enstate ./
COPY --from=builder /enstate/target/release/enstate /enstate/enstate

CMD ["/enstate/enstate"]
24 changes: 2 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Build
run: cargo build --release

- name: Create .dockerignore
run: echo 'target' > .dockerignore

- name: Move the binary to the root
run: mv target/release/enstate .

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
Expand All @@ -66,3 +44,5 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
file: .github/.deploy/Dockerfile
context: .
cache-from: type=registry,ref=ghcr.io/v3xlabs/enstate:edge
cache-to: type=inline

0 comments on commit 9e868a2

Please sign in to comment.