Skip to content

Commit

Permalink
create a new image for fleetdb (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alva8756 authored Dec 15, 2023
1 parent 2144f38 commit a11cd98
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/container-scan-trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project_name: serverservice
project_name: fleetdb
before:
hooks:
- go mod download
Expand All @@ -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:
-
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 3 additions & 3 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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"]
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions quickstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit a11cd98

Please sign in to comment.