-
Notifications
You must be signed in to change notification settings - Fork 184
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
chore: add docker builds #16
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cccda3a
chore: update taskfile
abelanger5 866864a
Merge branch 'main' of https://github.com/hatchet-dev/hatchet into main
abelanger5 a1259eb
chore: add docker builds
abelanger5 0f0c64c
(temp) set to hardcoded tag
abelanger5 5bb47d5
chore: add frontend build
abelanger5 ba12235
chore: update job names
abelanger5 4021fca
chore: wrap up docker builds
abelanger5 719b71c
remove engine dockerfile
abelanger5 b6dedd6
add migrate dockerfile
abelanger5 b291067
add hatchet-migrate to release file
abelanger5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
on: | ||
push: | ||
tags: | ||
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
name: Create prerelease w/ binaries and static assets | ||
jobs: | ||
build-push-hatchet-api: | ||
name: hatchet-api | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
id: tag_name | ||
run: echo "tag=${GITHUB_TAG/refs\/tags\//}" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TAG: ${{ github.ref }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Login to GHCR | ||
id: login-ghcr | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Build | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.Dockerfile \ | ||
-t ghcr.io/hatchet-dev/hatchet/hatchet-api:${{steps.tag_name.outputs.tag}} \ | ||
--build-arg SERVER_TARGET=api \ | ||
--build-arg VERSION=${{steps.tag_name.outputs.tag}} \ | ||
. | ||
- name: Push to GHCR | ||
run: | | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-api:${{steps.tag_name.outputs.tag}} | ||
build-push-hatchet-engine: | ||
name: hatchet-engine | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
id: tag_name | ||
run: echo "tag=${GITHUB_TAG/refs\/tags\//}" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TAG: ${{ github.ref }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Login to GHCR | ||
id: login-ghcr | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Build | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.Dockerfile \ | ||
-t ghcr.io/hatchet-dev/hatchet/hatchet-engine:${{steps.tag_name.outputs.tag}} \ | ||
--build-arg SERVER_TARGET=engine \ | ||
--build-arg VERSION=${{steps.tag_name.outputs.tag}} \ | ||
. | ||
- name: Push to GHCR | ||
run: | | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-engine:${{steps.tag_name.outputs.tag}} | ||
build-push-hatchet-migrate: | ||
name: hatchet-migrate | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
id: tag_name | ||
run: echo "tag=${GITHUB_TAG/refs\/tags\//}" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TAG: ${{ github.ref }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Login to GHCR | ||
id: login-ghcr | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Build | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -f ./build/package/migrate.Dockerfile \ | ||
-t ghcr.io/hatchet-dev/hatchet/hatchet-migrate:${{steps.tag_name.outputs.tag}} \ | ||
. | ||
- name: Push to GHCR | ||
run: | | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-migrate:${{steps.tag_name.outputs.tag}} | ||
build-push-hatchet-frontend: | ||
name: hatchet-frontend | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
id: tag_name | ||
run: echo "tag=${GITHUB_TAG/refs\/tags\//}" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TAG: ${{ github.ref }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Login to GHCR | ||
id: login-ghcr | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Build | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -f ./build/package/frontend.Dockerfile \ | ||
-t ghcr.io/hatchet-dev/hatchet/hatchet-frontend:${{steps.tag_name.outputs.tag}} \ | ||
. | ||
- name: Push to GHCR | ||
run: | | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-frontend:${{steps.tag_name.outputs.tag}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
on: | ||
release: | ||
types: [released] | ||
name: Release | ||
jobs: | ||
push-hatchet-server: | ||
name: Push latest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
id: tag_name | ||
run: | | ||
tag=${GITHUB_TAG/refs\/tags\//} | ||
echo ::set-output name=tag::$tag | ||
env: | ||
GITHUB_TAG: ${{ github.ref }} | ||
- name: Login to GHCR | ||
id: login-ghcr | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Pull and push hatchet-api | ||
run: | | ||
docker pull ghcr.io/hatchet-dev/hatchet/hatchet-api:${{steps.tag_name.outputs.tag}} | ||
docker tag ghcr.io/hatchet-dev/hatchet/hatchet-api:${{steps.tag_name.outputs.tag}} ghcr.io/hatchet-dev/hatchet/hatchet-server:latest | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-api:latest | ||
- name: Pull and push hatchet-engine | ||
run: | | ||
docker pull ghcr.io/hatchet-dev/hatchet/hatchet-engine:${{steps.tag_name.outputs.tag}} | ||
docker tag ghcr.io/hatchet-dev/hatchet/hatchet-engine:${{steps.tag_name.outputs.tag}} ghcr.io/hatchet-dev/hatchet/hatchet-engine:latest | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-engine:latest | ||
- name: Pull and push hatchet-frontend | ||
run: | | ||
docker pull ghcr.io/hatchet-dev/hatchet/hatchet-frontend:${{steps.tag_name.outputs.tag}} | ||
docker tag ghcr.io/hatchet-dev/hatchet/hatchet-frontend:${{steps.tag_name.outputs.tag}} ghcr.io/hatchet-dev/hatchet/hatchet-frontend:latest | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-frontend:latest | ||
- name: Pull and push hatchet-migrate | ||
run: | | ||
docker pull ghcr.io/hatchet-dev/hatchet/hatchet-migrate:${{steps.tag_name.outputs.tag}} | ||
docker tag ghcr.io/hatchet-dev/hatchet/hatchet-migrate:${{steps.tag_name.outputs.tag}} ghcr.io/hatchet-dev/hatchet/hatchet-migrate:latest | ||
docker push ghcr.io/hatchet-dev/hatchet/hatchet-migrate:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM node:18-alpine as build | ||
|
||
WORKDIR /app | ||
COPY ./frontend/app/package.json ./frontend/app/package-lock.json ./ | ||
RUN npm install | ||
COPY ./frontend/app ./ | ||
RUN npm run build | ||
|
||
# Stage 2: Serve the built app with NGINX | ||
FROM nginx:alpine | ||
|
||
ARG APP_TARGET=client | ||
|
||
COPY ./build/package/nginx.conf /etc/nginx/nginx.conf | ||
RUN rm -rf /usr/share/nginx/html/* | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/frontend/**/node_modules | ||
*.log | ||
/frontend/**/.DS_Store | ||
/frontend/**/.env | ||
/frontend/**/.cache | ||
/frontend/**/public/build | ||
/frontend/**/build | ||
/frontend/**/dist | ||
/frontend/**/.turbo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Base Go environment | ||
# ------------------- | ||
FROM golang:1.21-alpine as base | ||
WORKDIR /hatchet | ||
|
||
RUN apk update && apk add --no-cache gcc musl-dev git | ||
|
||
COPY go.mod go.sum ./ | ||
COPY /prisma ./prisma | ||
|
||
RUN go install github.com/steebchen/prisma-client-go@v0.31.2 | ||
|
||
# prefetch the binaries, so that they will be cached and not downloaded on each change | ||
RUN go run github.com/steebchen/prisma-client-go prefetch | ||
|
||
CMD go run github.com/steebchen/prisma-client-go migrate deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
worker_processes 4; | ||
|
||
events { worker_connections 1024; } | ||
|
||
http { | ||
server { | ||
listen 80; | ||
root /usr/share/nginx/html; | ||
include /etc/nginx/mime.types; | ||
index index.html index.htm; | ||
|
||
location / { | ||
try_files $uri /index.html; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Base Go environment | ||
# ------------------- | ||
FROM golang:1.21-alpine as base | ||
WORKDIR /hatchet | ||
|
||
RUN apk update && apk add --no-cache gcc musl-dev git protoc protobuf-dev | ||
|
||
COPY go.mod go.sum ./ | ||
COPY /api ./api | ||
COPY /api-contracts ./api-contracts | ||
COPY /internal ./internal | ||
COPY /pkg ./pkg | ||
COPY /hack ./hack | ||
COPY /prisma ./prisma | ||
COPY /cmd ./cmd | ||
|
||
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 | ||
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 | ||
RUN go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest | ||
|
||
RUN --mount=type=cache,target=$GOPATH/pkg/mod \ | ||
go mod download | ||
|
||
# prefetch the binaries, so that they will be cached and not downloaded on each change | ||
RUN go run github.com/steebchen/prisma-client-go prefetch | ||
|
||
# generate the Prisma Client Go client | ||
RUN go run github.com/steebchen/prisma-client-go generate --generator go | ||
|
||
# OpenAPI bundle environment | ||
# ------------------------- | ||
FROM node:16-alpine as build-openapi | ||
WORKDIR /openapi | ||
|
||
COPY /api-contracts/openapi ./openapi | ||
|
||
RUN npm install -g npm@8.1 | ||
|
||
RUN npm install -g @apidevtools/swagger-cli prisma | ||
|
||
RUN swagger-cli bundle ./openapi/openapi.yaml --outfile ./bin/oas/openapi.yaml --type yaml | ||
|
||
# Go build environment | ||
# -------------------- | ||
FROM base AS build-go | ||
|
||
ARG VERSION=v0.1.0-alpha.0 | ||
|
||
# can be set to "api" or "engine" | ||
ARG SERVER_TARGET | ||
|
||
# check if the target is empty or not set to api or engine | ||
RUN if [ -z "$SERVER_TARGET" ] || [ "$SERVER_TARGET" != "api" ] && [ "$SERVER_TARGET" != "engine" ]; then \ | ||
echo "SERVER_TARGET must be set to 'api' or 'engine'"; \ | ||
exit 1; \ | ||
fi | ||
|
||
RUN sh ./hack/proto/proto.sh | ||
|
||
COPY --from=build-openapi /openapi/bin/oas/openapi.yaml ./bin/oas/openapi.yaml | ||
|
||
# build oapi | ||
RUN oapi-codegen -config ./api/v1/server/oas/gen/codegen.yaml ./bin/oas/openapi.yaml | ||
|
||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=$GOPATH/pkg/mod \ | ||
go build -ldflags="-w -s -X 'main.Version=${VERSION}'" -a -o ./bin/hatchet-${SERVER_TARGET} ./cmd/hatchet-${SERVER_TARGET} | ||
|
||
# Deployment environment | ||
# ---------------------- | ||
FROM alpine AS deployment | ||
|
||
# can be set to "api" or "engine" | ||
ARG SERVER_TARGET=engine | ||
|
||
RUN apk update && apk add --no-cache gcc musl-dev | ||
|
||
COPY --from=build-go /hatchet/bin/hatchet-${SERVER_TARGET} /hatchet/ | ||
|
||
EXPOSE 8080 | ||
CMD /hatchet/hatchet-${SERVER_TARGET} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abelanger5 We should just do
go mod download
, otherwise this version will get out of sync with the one ingo.mod
.