diff options
| author | Baitinq <[email protected]> | 2024-05-01 13:02:40 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2024-05-01 16:25:18 +0200 |
| commit | 94f1c7d807d5392b870484b7112b4db6e0077813 (patch) | |
| tree | f9649777df0f1e4fc1a5216cdeec6009ac945629 /src | |
| parent | Create dummy rest-api service (diff) | |
| download | fs-tracer-backend-94f1c7d807d5392b870484b7112b4db6e0077813.tar.gz fs-tracer-backend-94f1c7d807d5392b870484b7112b4db6e0077813.tar.bz2 fs-tracer-backend-94f1c7d807d5392b870484b7112b4db6e0077813.zip | |
Build images with bazel
Diffstat (limited to 'src')
| -rw-r--r-- | src/rest-api/Dockerfile | 11 | ||||
| -rwxr-xr-x | src/rest-api/build-and-push-to-registry.sh | 1 | ||||
| -rw-r--r-- | src/rest-api/cmd/BUILD.bazel | 49 | ||||
| -rw-r--r-- | src/rest-api/go.mod | 3 |
4 files changed, 49 insertions, 15 deletions
diff --git a/src/rest-api/Dockerfile b/src/rest-api/Dockerfile deleted file mode 100644 index b8eccf0..0000000 --- a/src/rest-api/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM golang - -WORKDIR /app - -COPY . /app - -RUN go build cmd/main.go - -EXPOSE 8080 - -CMD ["/app/main"] diff --git a/src/rest-api/build-and-push-to-registry.sh b/src/rest-api/build-and-push-to-registry.sh deleted file mode 100755 index a132b7d..0000000 --- a/src/rest-api/build-and-push-to-registry.sh +++ /dev/null @@ -1 +0,0 @@ -docker buildx build -t docker.io/baitinq/fs-tracer:$(git rev-parse --short HEAD) --push . diff --git a/src/rest-api/cmd/BUILD.bazel b/src/rest-api/cmd/BUILD.bazel new file mode 100644 index 0000000..f72cc99 --- /dev/null +++ b/src/rest-api/cmd/BUILD.bazel @@ -0,0 +1,49 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_cross_binary", "go_library") +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball") +load("@rules_pkg//:pkg.bzl", "pkg_tar") + +go_library( + name = "cmd_lib", + srcs = ["main.go"], + importpath = "github.com/Baitinq/rest-api/src/rest-api/cmd", + visibility = ["//visibility:private"], +) + +go_binary( + name = "cmd", + embed = [":cmd_lib"], + visibility = ["//visibility:public"], +) + +go_cross_binary( + name = "cmd_arm64", + platform = "@io_bazel_rules_go//go/toolchain:linux_arm64", + target = ":cmd", + visibility = ["//visibility:public"], +) + +pkg_tar( + name = "tar", + srcs = [":cmd_arm64"], +) + +oci_image( + name = "image", + base = "@distroless_base", + entrypoint = ["/cmd_arm64"], + # architecture = "arm64", + # os = "linux", + tars = [":tar"], +) + +oci_tarball( + name = "tarball", + image = ":image", + repo_tags = [], +) + +oci_push( + name = "push", + image = ":image", + repository = "docker.io/baitinq/fs-tracer", +) diff --git a/src/rest-api/go.mod b/src/rest-api/go.mod deleted file mode 100644 index fe8def9..0000000 --- a/src/rest-api/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/Baitinq/rest-api - -go 1.22.2 |