Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 1. Build Stage
FROM rust:1.70 as builder

WORKDIR /usr/src/HelloWorld
WORKDIR /usr/src/hello_world
COPY . .
RUN cargo build --release

Expand All @@ -11,6 +11,6 @@ RUN cargo test --release

# 3. Distroless Stage
FROM gcr.io/distroless/cc-debian11
COPY --from=builder /usr/src/HelloWorld/target/release/HelloWorld /usr/local/bin/HelloWorld
COPY --from=builder /usr/src/hello_world/target/release/hello_world /usr/local/bin/hello_world

CMD ["HelloWorld"]
CMD ["hello_world"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ This project uses GitHub Actions for continuous integration. Upon each push to y

The artifacts will then be available for download from the "Actions" tab on your repository and also from the "Releases" tab for release events.

## Docker image

This project also contains `buildpush.sh` which will build a distroless Docker image with the application as the entry point. By default, the
script will push the built multi-arch images to DockerHub. [Here](https://hub.docker.com/r/richardsondev/hello_world/tags) is an example of
what it would look like.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
Expand Down
7 changes: 4 additions & 3 deletions buildpush.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# Builds distroless Docker images with the application and pushes them to Docker Hub
# Currently, intended to be run from a local machine

APP_NAME="<Your application>"
DOCKER_HUB="<Your Docker Hub username>"
APP_NAME="hello_world"
DOCKER_HUB="YourDockerHubUsername"

# Step 1: Build the Docker image and push to Docker Hub
# This builds and pushes ARM32, ARM64, and X64 images
docker buildx create --use --name mybuilder || true
docker buildx use mybuilder
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t $DOCKER_HUB/$APP_NAME:latest --push
docker buildx build . --platform linux/amd64,linux/arm64,linux/arm/v7 -t $DOCKER_HUB/$APP_NAME:latest --push