diff --git a/.dockerignore b/.dockerignore index e9eafac..e69de29 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +0,0 @@ -Dockerfile -go.mod -go.sum -main.go -Makefile diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 3b73f77..7e135a8 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -8,8 +8,6 @@ on: jobs: build-and-publish: runs-on: ubuntu-latest - strategy: - fail-fast: false env: IMAGE_NAME: ses-smtpd-proxy steps: @@ -37,7 +35,7 @@ jobs: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV echo "IMAGE_VERSION=$(cat version.txt)" >> $GITHUB_ENV - - name: Build and scan image + - name: Build image run: | docker build --no-cache -t ${IMAGE_NAME} -t localimage:localtag . diff --git a/Dockerfile b/Dockerfile index 288ccaf..ed31ba3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,11 @@ FROM golang:1.18 as build -WORKDIR /go/src/ses-smtpd-proxy -COPY . . +WORKDIR /go/src/app +COPY . /go/src/app -RUN go mod download -RUN go vet -v -RUN go test -v - -RUN CGO_ENABLED=0 go build -o ses-smtpd-proxy +RUN CGO_ENABLED=0 go build -o /go/bin/app FROM gcr.io/distroless/static-debian11 -ADD ses-smtpd-proxy / - -CMD [ "/ses-smtpd-proxy" ] +COPY --from=build /go/bin/app / +CMD ["/app"] \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 0f18e4f..0000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -BINARY ?= ses-smtpd-proxy -DOCKER_IMAGE ?= docker.crute.me/ses-email-proxy:latest - -$(BINARY): main.go go.sum smtpd/smtpd.go - CGO_ENABLED=0 go build -o $@ $< - -.PHONY: docker -docker: $(BINARY) - docker build -t $(DOCKER_IMAGE) . - -.PHONY: publish -publish: docker - docker push $(DOCKER_IMAGE) - -go.sum: go.mod - go mod tidy - -.PHONY: clean -clean: - rm $(BINARY) || true