Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(Dockerfile): add Go SDK to resulting image #1357

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading