Skip to content

Commit

Permalink
Added support for building different architecture
Browse files Browse the repository at this point in the history
 - Parametrized Dockerfile with ARCH build argument¨
 - Bumped rust version to 1.72
  • Loading branch information
richardfelkl committed Sep 21, 2023
1 parent 5ff3775 commit 4b0d2a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ docker build --tag sentry_tunnel:latest . # Build docker image
#docker tag <ID> sigalen/sentry_tunnel:latest # Create image tag (in case of build fail)
docker push sigalen/sentry_tunnel:latest
```

## Building for a different architecture

```
docker build --tag sentry_tunnel:latest --build-arg ARCH=aarch64 .
```
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
####################################################################################################
## Builder
####################################################################################################
FROM rust:1.55 AS builder
FROM rust:1.72 AS builder

RUN rustup target add x86_64-unknown-linux-musl
ARG ARCH=x86_64

RUN rustup target add ${ARCH}-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev libssl-dev pkg-config curl g++
RUN update-ca-certificates

Expand All @@ -26,7 +28,7 @@ WORKDIR /sentry_tunnel
RUN touch src/lib.rs
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN cargo build --target x86_64-unknown-linux-musl --release
RUN cargo build --target ${ARCH}-unknown-linux-musl --release

# Dependency have been built, remove the empty app and copy real source
RUN rm src/*.rs
Expand All @@ -35,7 +37,7 @@ RUN touch src/main.rs
RUN touch src/lib.rs
RUN rm -f ./target/release/deps/sentry_tunnel*
RUN rm -f ./target/release/deps/libsentry_tunnel*
RUN cargo build --target x86_64-unknown-linux-musl --release
RUN cargo build --target ${ARCH}-unknown-linux-musl --release


#===========================#
Expand All @@ -57,7 +59,7 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
WORKDIR /sentry_tunnel

# Copy our build
COPY --from=builder /sentry_tunnel/target/x86_64-unknown-linux-musl/release/sentry_tunnel ./
COPY --from=builder /sentry_tunnel/target/${ARCH}-unknown-linux-musl/release/sentry_tunnel ./
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Use an unprivileged user.
USER sentry_tunnel:sentry_tunnel
Expand Down

0 comments on commit 4b0d2a0

Please sign in to comment.