Skip to content

Commit

Permalink
Merge pull request #1357 from tdakkota/ci/fix-docker-image
Browse files Browse the repository at this point in the history
ci(Dockerfile): add Go SDK to resulting image
  • Loading branch information
tdakkota authored Dec 3, 2024
2 parents 35d970b + 46f9be4 commit 33a9ec0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,21 @@ jobs:
- name: Run tests
run: cd examples && go test ./...

ensure-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build image
run: |
docker build . \
--tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
- name: Check image
run: |
docker run \
-v ./_testdata/examples/petstore.yml:/petstore.yml \
--rm \
ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA /petstore.yml
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
ARG GO_VERSION=latest

FROM golang:$GO_VERSION as builder

FROM golang:$GO_VERSION AS builder
WORKDIR /go/src/app

COPY . .

RUN go mod download

RUN CGO_ENABLED=0 go build -o /go/bin/ogen ./cmd/ogen/main.go

FROM scratch

# We need go in resulting image to run goimports.
COPY --from=builder /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
# Copy built binary.
WORKDIR /

COPY --from=builder /go/bin/ogen ./ogen

ENTRYPOINT ["./ogen"]

0 comments on commit 33a9ec0

Please sign in to comment.