From a11cd988b70518fe9fc9fcfd63c63e760cf82012 Mon Sep 17 00:00:00 2001 From: Alva Zhang <140438385+Alva8756@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:39:52 -0800 Subject: [PATCH] create a new image for fleetdb (#7) --- .github/workflows/container-scan-trivy.yml | 2 +- .goreleaser.yml | 3 ++- Dockerfile | 4 ++-- Dockerfile.dev | 6 +++--- Makefile | 12 ++++++------ quickstart.yml | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/container-scan-trivy.yml b/.github/workflows/container-scan-trivy.yml index d8a987b..5b1c8b6 100644 --- a/.github/workflows/container-scan-trivy.yml +++ b/.github/workflows/container-scan-trivy.yml @@ -25,7 +25,7 @@ jobs: - name: Build go binary run: | - go build -o serverservice . + go build -o fleetdb . - name: Build uses: docker/build-push-action@v4 diff --git a/.goreleaser.yml b/.goreleaser.yml index dd4b8c6..7159cd9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: serverservice +project_name: fleetdb before: hooks: - go mod download @@ -18,6 +18,7 @@ builds: - -X go.infratographer.com/x/versionx.commit={{.Commit}} - -X go.infratographer.com/x/versionx.date={{.Date}} - -X go.infratographer.com/x/versionx.builtBy=goreleaser + binary: fleetdb archives: - diff --git a/Dockerfile b/Dockerfile index 8459d81..03b1e8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM gcr.io/distroless/static # Copy the binary that goreleaser built -COPY serverservice /serverservice +COPY fleetdb /fleetdb # Run the web service on container startup. -ENTRYPOINT ["/serverservice"] +ENTRYPOINT ["/fleetdb"] CMD ["serve"] diff --git a/Dockerfile.dev b/Dockerfile.dev index 397d072..875a961 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -16,7 +16,7 @@ RUN go mod tidy # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. RUN export LDFLAG_LOCATION="go.infratographer.com/x/versionx" && \ - CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o serverservice \ + CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o fleetdb \ -ldflags \ "-X ${LDFLAG_LOCATION}.appName=serverservice \ -X ${LDFLAG_LOCATION}.commit=$(git rev-parse --short HEAD) \ @@ -30,8 +30,8 @@ FROM alpine:3.18.3 RUN apk add --no-cache ca-certificates # Copy the binary to the production image from the builder stage. -COPY --from=builder /app/serverservice /serverservice +COPY --from=builder /app/fleetdb /fleetdb # Run the web service on container startup. -ENTRYPOINT ["/serverservice"] +ENTRYPOINT ["/fleetdb"] CMD ["serve"] diff --git a/Makefile b/Makefile index 1e92cb6..8fa08a0 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ GOOS=linux DB_STRING=host=localhost port=26257 user=root sslmode=disable DEV_DB=${DB_STRING} dbname=serverservice TEST_DB=${DB_STRING} dbname=serverservice_test -DOCKER_IMAGE := "ghcr.io/metal-toolbox/hollow-serverservice" +DOCKER_IMAGE := "ghcr.io/metal-toolbox/fleetdb" ## run all tests test: | unit-test integration-test @@ -72,9 +72,9 @@ test-database: | vendor ## Build linux bin build-linux: - GOOS=linux GOARCH=amd64 go build -o serverservice + GOOS=linux GOARCH=amd64 go build -o fleetdb -## build docker image and tag as ghcr.io/metal-toolbox/hollow-serverservice:latest +## build docker image and tag as ghcr.io/metal-toolbox/fleetdb:latest build-image: build-linux docker build --rm=true -f Dockerfile -t ${DOCKER_IMAGE}:latest . \ --label org.label-schema.schema-version=1.0 \ @@ -83,9 +83,9 @@ build-image: build-linux ## build and push devel docker image to KIND image repo used by the sandbox - https://github.com/metal-toolbox/sandbox push-image-devel: build-image - docker tag ${DOCKER_IMAGE}:latest localhost:5001/serverservice:latest - docker push localhost:5001/serverservice:latest - kind load docker-image localhost:5001/serverservice:latest + docker tag ${DOCKER_IMAGE}:latest localhost:5001/fleetdb:latest + docker push localhost:5001/fleetdb:latest + kind load docker-image localhost:5001/fleetdb:latest # https://gist.github.com/prwhite/8168133 diff --git a/quickstart.yml b/quickstart.yml index 276106e..9bf38bb 100644 --- a/quickstart.yml +++ b/quickstart.yml @@ -2,7 +2,7 @@ version: "3.9" services: serverservice: - image: ghcr.io/metal-toolbox/hollow-serverservice:v0.16.0 + image: ghcr.io/metal-toolbox/fleetdb:v0.16.0 depends_on: - crdb - serverservice-migrate @@ -17,7 +17,7 @@ services: - hollow serverservice-migrate: - image: ghcr.io/metal-toolbox/hollow-serverservice:v0.16.0 + image: ghcr.io/metal-toolbox/fleetdb:v0.16.0 command: migrate up depends_on: