Skip to content

Commit

Permalink
build image within container
Browse files Browse the repository at this point in the history
  • Loading branch information
simonycj committed Mar 20, 2024
1 parent 59bc732 commit 1b244cb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ jobs:
with:
fetch-depth: 0

- name: Build
run: make go-build

- name: Extract Tag
id: extract_tag
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
Expand Down Expand Up @@ -68,4 +65,4 @@ jobs:
echo extract_branch ${{ steps.extract_branch.outputs.branch }}
echo current tag is ${tag}
docker buildx build --platform linux/amd64,linux/arm64 --push --file hack/builder/Dockerfile -t 99cloud/open-hydra-server:${tag} .
docker buildx build --platform linux/amd64,linux/arm64 --push -t 99cloud/open-hydra-server:${tag} .
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.21.8-alpine3.19 as build
ENV GOPROXY=https://goproxy.cn
WORKDIR /openhydra
COPY . /openhydra
RUN apk add make bash which && make go-build

FROM rockylinux:8.8
COPY --from=build /openhydra/cmd/open-hydra-server/open-hydra-server /usr/bin/
EXPOSE 443
WORKDIR /usr/bin
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ vet:

.PHONY: go-build
go-build:
CGO_ENABLED=0 go build -o cmd/open-hydra-server/open-hydra-server -ldflags "-X 'main.version=${TAG}'" cmd/open-hydra-server/main.go
CGO_ENABLED=0 GOARCH=$(GOARCH) go build -o cmd/open-hydra-server/open-hydra-server -ldflags "-X 'main.version=${TAG}'" cmd/open-hydra-server/main.go

.PHONY: image
image: go-build
docker build -f hack/builder/Dockerfile -t $(REGISTRY)/open-hydra-server:$(IMAGETAG) .
docker build -t $(REGISTRY)/open-hydra-server:$(IMAGETAG) .
6 changes: 0 additions & 6 deletions hack/builder/Dockerfile

This file was deleted.

0 comments on commit 1b244cb

Please sign in to comment.