Update Dockerfile and add GitHub Actions workflow
- Fix run cmd - Fix incorrect image name after build
- commit
- 9002bf817b4f6a19215ebb6a09a477010fc5a980
- author
- bamen · · 2024-08-27 08:03 UTC
- committer
- bamen · · 2024-08-27 08:19 UTC
- parent
- 97319bf
- signature
- unsigned
2 files · +47 -5
A .github/workflows/build_dev.yml +39 -0
| @@ -0,0 +1,39 @@ | |||
| 1 | + | name: Build and Test Gordon | |
| 2 | + | ||
| 3 | + | on: | |
| 4 | + | push: | |
| 5 | + | branches: | |
| 6 | + | - "dev" | |
| 7 | + | ||
| 8 | + | jobs: | |
| 9 | + | build-and-test: | |
| 10 | + | name: Build and Test | |
| 11 | + | runs-on: ubuntu-latest | |
| 12 | + | permissions: | |
| 13 | + | contents: read | |
| 14 | + | packages: write | |
| 15 | + | env: | |
| 16 | + | KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | |
| 17 | + | ||
| 18 | + | steps: | |
| 19 | + | - uses: actions/setup-go@v4 | |
| 20 | + | with: | |
| 21 | + | go-version: "1.23" | |
| 22 | + | ||
| 23 | + | - uses: actions/checkout@v3 | |
| 24 | + | ||
| 25 | + | # - name: Run tests | |
| 26 | + | # run: go test ./... | |
| 27 | + | ||
| 28 | + | - name: Log in to GitHub Container Registry | |
| 29 | + | uses: docker/login-action@v2 | |
| 30 | + | with: | |
| 31 | + | registry: ghcr.io | |
| 32 | + | username: ${{ github.actor }} | |
| 33 | + | password: ${{ secrets.GITHUB_TOKEN }} | |
| 34 | + | ||
| 35 | + | - uses: ko-build/setup-ko@v0.6 | |
| 36 | + | ||
| 37 | + | - name: Build and push with ko | |
| 38 | + | run: | | |
| 39 | + | ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev | |
| @@ -0,0 +1,39 @@ | |||||
| 1 | + | name: Build and Test Gordon | |||
| 2 | + | ||||
| 3 | + | on: | |||
| 4 | + | push: | |||
| 5 | + | branches: | |||
| 6 | + | - "dev" | |||
| 7 | + | ||||
| 8 | + | jobs: | |||
| 9 | + | build-and-test: | |||
| 10 | + | name: Build and Test | |||
| 11 | + | runs-on: ubuntu-latest | |||
| 12 | + | permissions: | |||
| 13 | + | contents: read | |||
| 14 | + | packages: write | |||
| 15 | + | env: | |||
| 16 | + | KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | |||
| 17 | + | ||||
| 18 | + | steps: | |||
| 19 | + | - uses: actions/setup-go@v4 | |||
| 20 | + | with: | |||
| 21 | + | go-version: "1.23" | |||
| 22 | + | ||||
| 23 | + | - uses: actions/checkout@v3 | |||
| 24 | + | ||||
| 25 | + | # - name: Run tests | |||
| 26 | + | # run: go test ./... | |||
| 27 | + | ||||
| 28 | + | - name: Log in to GitHub Container Registry | |||
| 29 | + | uses: docker/login-action@v2 | |||
| 30 | + | with: | |||
| 31 | + | registry: ghcr.io | |||
| 32 | + | username: ${{ github.actor }} | |||
| 33 | + | password: ${{ secrets.GITHUB_TOKEN }} | |||
| 34 | + | ||||
| 35 | + | - uses: ko-build/setup-ko@v0.6 | |||
| 36 | + | ||||
| 37 | + | - name: Build and push with ko | |||
| 38 | + | run: | | |||
| 39 | + | ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev | |||
M Dockerfile +8 -5
| @@ -1,9 +1,12 @@ | |||
| 1 | - | # Use a small base image | |
| 1 | + | # Use a minimal base image | |
| 2 | 2 | FROM alpine | |
| 3 | - | ARG BINARY | |
| 3 | + | # Install ca-certificates bundle | |
| 4 | + | RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* | |
| 5 | + | # Copy the binary | |
| 6 | + | COPY gordon /gordon | |
| 7 | + | # Copy other necessary files | |
| 4 | 8 | COPY .iscontainer / | |
| 5 | - | COPY gordon / | |
| 9 | + | # Set the entrypoint | |
| 6 | 10 | ENTRYPOINT ["/gordon"] | |
| 7 | - | ||
| 8 | - | # Default command when running the container | |
| 11 | + | # Default command | |
| 9 | 12 | CMD ["serve"] | |
| @@ -1,9 +1,12 @@ | |||||
| 1 | - | # Use a small base image | 1 | + | # Use a minimal base image |
| 2 | FROM alpine | 2 | FROM alpine | ||
| 3 | - | ARG BINARY | 3 | + | # Install ca-certificates bundle |
| 4 | + | RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* | |||
| 5 | + | # Copy the binary | |||
| 6 | + | COPY gordon /gordon | |||
| 7 | + | # Copy other necessary files | |||
| 4 | COPY .iscontainer / | 8 | COPY .iscontainer / | ||
| 5 | - | COPY gordon / | 9 | + | # Set the entrypoint |
| 6 | ENTRYPOINT ["/gordon"] | 10 | ENTRYPOINT ["/gordon"] | ||
| 7 | - | 11 | + | # Default command | |
| 8 | - | # Default command when running the container | |||
| 9 | CMD ["serve"] | 12 | CMD ["serve"] | ||