From c2fc742cb67bfe2b2d9fdbca952dd944e5f794a2 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Mon, 14 Jun 2021 16:58:13 -0400 Subject: [PATCH 1/6] WIP: use native goreleaser instead of docker version --- .goreleaser.yml | 12 ++++++++---- Brewfile | 1 + script/build | 15 ++------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index a242431f79..d41e78d90d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,6 +2,11 @@ builds: - main: ./cmd/flipt/. env: - CGO_ENABLED=1 + - CC=x86_64-linux-musl-gcc + - CXX=x86_64-linux-musl-g++ + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} + - -linkmode external -extldflags -static goos: - linux goarch: @@ -15,7 +20,7 @@ archives: - LICENSE - README.md - CHANGELOG.md - - ./config/migrations/*/** + - ./config/migrations/ - ./config/default.yml checksum: @@ -26,8 +31,6 @@ changelog: dockers: - dockerfile: ./build/Dockerfile - binaries: - - flipt skip_push: true image_templates: - "markphelps/flipt:latest" @@ -39,4 +42,5 @@ dockers: - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.version={{.Version}}" extra_files: - - config + - config/migrations/ + - config/default.yml \ No newline at end of file diff --git a/Brewfile b/Brewfile index f60d6f44a7..7605f35c75 100644 --- a/Brewfile +++ b/Brewfile @@ -3,3 +3,4 @@ brew "cmake" brew "pkg-config" brew "sqlite" brew "protobuf" +brew "FiloSottile/musl-cross/musl-cross" \ No newline at end of file diff --git a/script/build b/script/build index 8440f0ed00..f26f8db234 100755 --- a/script/build +++ b/script/build @@ -2,30 +2,19 @@ set -euo pipefail -GORELEASER_VERSION=v0.148.0 - cd "$(dirname "$0")/.." || exit case "$1" in "release") github-release-notes -org markphelps -repo flipt --since-latest-release | tee release.out - docker run --rm --privileged \ - -v "$PWD":/flipt \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -w /flipt \ - -e GITHUB_TOKEN \ - goreleaser/goreleaser:"$GORELEASER_VERSION"-cgo --rm-dist --release-notes release.out + goreleaser --rm-dist --release-notes release.out rm release.out ;; "snapshot") - docker run --rm --privileged \ - -v "$PWD":/flipt \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -w /flipt \ - goreleaser/goreleaser:"$GORELEASER_VERSION"-cgo --rm-dist --snapshot + goreleaser --rm-dist --snapshot ;; "clients") From c4fb0ba343399f669e664806cb08af0ddc715983 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Mon, 14 Jun 2021 16:58:54 -0400 Subject: [PATCH 2/6] Add goreleaser to bundle --- Brewfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Brewfile b/Brewfile index 7605f35c75..87289f2455 100644 --- a/Brewfile +++ b/Brewfile @@ -1,6 +1,7 @@ -brew "go" -brew "cmake" -brew "pkg-config" -brew "sqlite" -brew "protobuf" -brew "FiloSottile/musl-cross/musl-cross" \ No newline at end of file +brew 'go' +brew 'cmake' +brew 'pkg-config' +brew 'sqlite' +brew 'protobuf' +brew 'FiloSottile/musl-cross/musl-cross' +brew 'goreleaser/tap/goreleaser' From 04a2abab93191caafe0a1bd7f38a6764ee230995 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Tue, 15 Jun 2021 09:38:43 -0400 Subject: [PATCH 3/6] use buildx --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index d41e78d90d..6e89428560 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -31,7 +31,7 @@ changelog: dockers: - dockerfile: ./build/Dockerfile - skip_push: true + use_buildx: true image_templates: - "markphelps/flipt:latest" - "markphelps/flipt:{{ .Tag }}" From 3f6d18d5045a51861a687d4ab3adada9e5428009 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Tue, 15 Jun 2021 09:46:11 -0400 Subject: [PATCH 4/6] Goreleaser config --- .goreleaser.yml | 4 ++-- build/Dockerfile | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 6e89428560..180dc9ae1f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -21,7 +21,7 @@ archives: - README.md - CHANGELOG.md - ./config/migrations/ - - ./config/default.yml + - ./config/*.yml checksum: name_template: 'checksums.txt' @@ -43,4 +43,4 @@ dockers: - "--label=org.opencontainers.image.version={{.Version}}" extra_files: - config/migrations/ - - config/default.yml \ No newline at end of file + - config/*.yml \ No newline at end of file diff --git a/build/Dockerfile b/build/Dockerfile index 84a4d20835..5dd08e8056 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,8 +1,9 @@ # https://goreleaser.com/docker/ ARG BINARY=flipt +ARG ALPINE_VERSION=3.10.9 -FROM alpine:3.10 +FROM alpine:${ALPINE_VERSION} LABEL maintainer="mark.aaron.phelps@gmail.com" LABEL org.opencontainers.image.name="flipt" LABEL org.opencontainers.image.source="https://github.com/markphelps/flipt" @@ -21,7 +22,4 @@ COPY config/*.yml /etc/flipt/config/ EXPOSE 8080 EXPOSE 9000 -# Docker exposes container ports to the IP address 0.0.0.0 -ENV FLIPT_SERVER_HOST 0.0.0.0 - CMD ["./flipt"] From 4e045844dca57a6e0077cb6b918d592f6550fb8c Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Tue, 15 Jun 2021 09:50:33 -0400 Subject: [PATCH 5/6] Fix config --- .goreleaser.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 180dc9ae1f..ca501a0823 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -21,7 +21,7 @@ archives: - README.md - CHANGELOG.md - ./config/migrations/ - - ./config/*.yml + - ./config/default.yml checksum: name_template: 'checksums.txt' @@ -42,5 +42,5 @@ dockers: - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.version={{.Version}}" extra_files: - - config/migrations/ - - config/*.yml \ No newline at end of file + - ./config/migrations/ + - ./config/default.yml \ No newline at end of file From f1c05a36670307e1bc27f42819c3271cfe56b433 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Tue, 15 Jun 2021 09:53:55 -0400 Subject: [PATCH 6/6] Fix docker build --- .goreleaser.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index ca501a0823..6e89428560 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -42,5 +42,5 @@ dockers: - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.version={{.Version}}" extra_files: - - ./config/migrations/ - - ./config/default.yml \ No newline at end of file + - config/migrations/ + - config/default.yml \ No newline at end of file