From 29a4ed3f5f755b40663971edba2f80c831f98d2f Mon Sep 17 00:00:00 2001 From: Billy Richardson Date: Thu, 22 Jun 2023 03:44:39 -0700 Subject: [PATCH 1/2] Clean up the Docker image build script --- Dockerfile | 6 +++--- README.md | 6 ++++++ buildpush.sh | 7 ++++--- 3 files changed, 13 insertions(+), 6 deletions(-) mode change 100644 => 100755 buildpush.sh diff --git a/Dockerfile b/Dockerfile index b4c641b..65e0696 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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"] diff --git a/README.md b/README.md index a0cf2ce..17b9255 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/buildpush.sh b/buildpush.sh old mode 100644 new mode 100755 index 57fd2a2..775e7cc --- a/buildpush.sh +++ b/buildpush.sh @@ -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="" -DOCKER_HUB="" +APP_NAME="hello_world" +DOCKER_HUB="richardsondev" # 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 + From 4f262d92454098c949e224ea19237e3e241e4ce5 Mon Sep 17 00:00:00 2001 From: Billy Richardson Date: Thu, 22 Jun 2023 03:47:19 -0700 Subject: [PATCH 2/2] Generic name --- buildpush.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildpush.sh b/buildpush.sh index 775e7cc..42f8e64 100755 --- a/buildpush.sh +++ b/buildpush.sh @@ -4,7 +4,7 @@ # Currently, intended to be run from a local machine APP_NAME="hello_world" -DOCKER_HUB="richardsondev" +DOCKER_HUB="YourDockerHubUsername" # Step 1: Build the Docker image and push to Docker Hub # This builds and pushes ARM32, ARM64, and X64 images