Skip to content

Commit

Permalink
Merge pull request #25 from njhale/chore-docker-builds
Browse files Browse the repository at this point in the history
chore: add docker build ci
  • Loading branch information
ibuildthecloud authored Feb 13, 2024
2 parents 53e4d23 + f1850a2 commit 2f47d40
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 3 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ on:

permissions:
contents: write
packages: write

jobs:
release-snapshot:
release-main:
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -24,7 +25,20 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: "1.21"
go-version: "1.22"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand All @@ -34,3 +48,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PROJECT_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }}
- name: Push Docker Images
run: |
VERSION=v$(cat releases/metadata.json | jq -r .version)
IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "$VERSION")
for i in ${IMAGES}; do
docker push $i
done
docker manifest create ghcr.io/gptscript-ai/gptscript:main ${IMAGES}
docker manifest push ghcr.io/gptscript-ai/gptscript:main
docker manifest create ghcr.io/gptscript-ai/gptscript:${VERSION} ${IMAGES}
docker manifest push ghcr.io/gptscript-ai/gptscript:${VERSION}
15 changes: 14 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: "1.21"
go-version: "1.22"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,43 @@ brews:
owner: gptscript-ai
name: homebrew-tap
token: "{{ .Env.GH_PROJECT_TOKEN }}"

dockers:
- use: buildx
goos: linux
goarch: amd64
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source=https://github.com/gptscript-ai/gptscript"
- "--platform=linux/amd64"
- use: buildx
goos: linux
goarch: arm64
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source=https://github.com/gptscript-ai/gptscript"
- "--platform=linux/arm64"

docker_manifests:
- use: docker
name_template: ghcr.io/gptscript-ai/gptscript:v{{ .Version }}
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
- use: docker
name_template: ghcr.io/gptscript-ai/gptscript:latest
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.22.0-alpine3.19 AS build
RUN apk add -U --no-cache make git
COPY / /src/gptscript
WORKDIR /src/gptscript
RUN make build

FROM alpine AS release
COPY --from=build /src/gptscript/bin /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/gptscript"]

0 comments on commit 2f47d40

Please sign in to comment.