Skip to content

Commit

Permalink
some cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
kriscfoster committed Aug 27, 2023
1 parent 8ceb4c2 commit b38397a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,28 @@ Loaded image: projects/node_web:oci_tarball
listening on port 8080
```

### Build & Run Go web app docker image
### Build & Run Go web app docker image (amd64)
```
➜ bazel run projects/go_web:oci_tarball --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64
➜ bazel run projects/go_web:oci_tarball_amd64
...
Loaded image: projects/go_web:oci_tarball
Loaded image: projects/go_web:oci_tarball_amd64
➜ docker run -p 8080:8080 projects/go_web:oci_tarball
2022/05/30 20:35:51 Going to listen on port 8080
➜ docker run projects/go_web:oci_tarball_amd64
2023/08/27 13:40:22 running program's operating system target: linux
2023/08/27 13:40:22 running program's architecture target: amd64
2023/08/27 13:40:22 Going to listen on port: 8080
```

### Build & Run Go web app docker image (arm64)
```
➜ bazel run projects/go_web:oci_tarball_arm64
...
Loaded image: projects/go_web:oci_tarball_arm64
➜ docker run projects/go_web:oci_tarball_arm64
2023/08/27 13:40:58 running program's operating system target: linux
2023/08/27 13:40:58 running program's architecture target: arm64
2023/08/27 13:40:58 Going to listen on port: 8080
```

### Deploying Go web app to Heroku
Expand Down
42 changes: 16 additions & 26 deletions projects/go_web/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ go_library(
],
)

go_binary(
name = "go_web",
embed = [":go_web_lib"],
visibility = ["//visibility:public"],
)

pkg_tar(
name = "tar",
srcs = [":go_web"],
)

oci_image(
name = "oci_image",
base = "@distroless_base",
# with :debug distroless image, entrypoint can be changed to "sh" for debug purposes
entrypoint = ["go_web_/go_web"],
tars = [":tar"],
)

archs = [
"arm64",
"amd64",
Expand Down Expand Up @@ -68,6 +49,15 @@ archs = [
for arch in archs
]

[
oci_tarball(
name = "oci_tarball_" + arch,
image = ":oci_image_" + arch,
repo_tags = ["projects/go_web:oci_tarball_" + arch],
)
for arch in archs
]

oci_image_index(
name = "multi_arch_image",
images = [
Expand All @@ -83,14 +73,14 @@ oci_push(
repository = "registry.hub.docker.com/krisfoster96/monorepo-go-web",
)

oci_tarball(
name = "oci_tarball_amd64",
image = ":oci_image_amd64",
repo_tags = ["projects/go_web:oci_tarball_amd64"],
)

bazoku(
name = "bazoku-deployment",
binary = ":go_web",
binary = ":go_web_amd64",
heroku_app_name = "my-bazoku-app",
)

go_binary(
name = "go_web",
embed = [":go_web_lib"],
visibility = ["//visibility:public"],
)

0 comments on commit b38397a

Please sign in to comment.