Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MicroServices and MonoRepo

MicroServices and MonoRepo

Golangのマイクロサービスをmono repositoryでBazelを利用して管理する方法についてお話しました。

Hiroaki Egashira

August 06, 2019
Tweet

More Decks by Hiroaki Egashira

Other Decks in Programming

Transcript

  1. .POP3FQPTJUPSZ ˝ (PPHMF 'BDFCPPL 5XJUUFS׵⺱喋 ˝ ❣㰆畘杼؅ب٤وٜמך׀׾ ˝ ┉鞉䓪סֵ׾㚺催 ˝

    ؤ٭غס⪦僗כ⫋⮵榫ֿ㳊佄 ˝ 㛻׀םٛنؒؠذٛ٤ءֿ㳊佄 חסَٝةعٛךخ٭تؤ٭غ؅畘杼
  2. .POP3FQPTJUPSZ ˝ (PPHMF 'BDFCPPL 5XJUUFS׵⺱喋 ˝ ❣㰆畘杼؅ب٤وٜמך׀׾ ˝ ┉鞉䓪סֵ׾㚺催 ˝

    ؤ٭غס⪦僗כ⫋⮵榫ֿ㳊佄 ˝ 㛻׀םٛنؒؠذٛ٤ءֿ㳊佄 חסَٝةعٛךخ٭تؤ٭غ؅畘杼
  3. .POP3FQPTJUPSZ ˝ (PPHMF 'BDFCPPL 5XJUUFS׵⺱喋 ˝ ❣㰆畘杼؅ب٤وٜמך׀׾ ˝ ┉鞉䓪סֵ׾㚺催 ˝

    ؤ٭غס⪦僗כ⫋⮵榫ֿ㳊佄 ˝ 㛻׀םٛنؒؠذٛ٤ءֿ㳊佄 חסَٝةعٛךخ٭تؤ٭غ؅畘杼
  4. #B[FM ˝ (P 1SPUPDPM#VFS $ +"7" "OESPJE J04 םל喋չם銧鏤מ㵚䑴 ˝

    䑒釐ם甙䢥דׄ؅لٜغ٬طتع׌׾סך鵭ַ ˝ تآ٭ٚهٜ ˝ 䦡䍖⺎耆 لٜغ٬طتعبتطّ
  5. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", urls = [ "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.19.1/rules_go-0.19.1.tar.gz",

    "https://github.com/bazelbuild/rules_go/releases/download/0.19.1/rules_go-0.19.1.tar.gz", ], sha256 = "8df59f11fb697743cbb3f26cfb8750395f30471e9eabde0d174c3aebc7a1cd39", ) load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") go_rules_dependencies() go_register_toolchains() http_archive( name = "bazel_gazelle", urls = [ "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz", "https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz", ], sha256 = "be9296bfd64882e3c08e3283c58fcb461fa6dd3c171764fcc4cf322f60615a9b", ) load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") gazelle_dependencies() 803,41"$& SVMFT@HP (B[FMMF
  6. $ tree . !"" BUILD.bazel !"" WORKSPACE #"" cmd #""

    main.go $ bazel run //:gazelle (B[FMMF
  7. $ tree . !"" BUILD.bazel !"" WORKSPACE #"" cmd !""

    BUILD.bazel #"" main.go $ cat cmd/BUILD.bazel load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["main.go"], importpath = "github.com/hiro511/golang-bazel/cmd", visibility = ["//visibility:public"], ) (B[FMMF ̚舅Ⳃ榟䡗׈׿׾
  8. $ cat cmd/BUILD.bazel load("@io_bazel_rules_go//go:def.bzl", “go_library”, “go_binary”) go_library( name = "go_default_library",

    srcs = ["main.go"], importpath = "github.com/hiro511/golang-bazel/cmd", visibility = ["//visibility:public"], ) go_binary( name = “hello", embed = [":go_default_library"], visibility = ["//visibility:public"], ) $ bazel run //cmd:hello INFO: Analyzed target //cmd:hello (1 packages loaded, 3 targets configured). INFO: Found 1 target... Target //cmd:hello up-to-date: bazel-bin/cmd/darwin_amd64_stripped/hello INFO: Elapsed time: 0.533s, Critical Path: 0.37s INFO: 2 processes: 2 darwin-sandbox. INFO: Build completed successfully, 5 total actions INFO: Build completed successfully, 5 total actions hello world 3VO فؕػٜٛ٭ٜ