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

feat: add docker build and push actions #104

Merged
merged 3 commits into from
Oct 15, 2023
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
69 changes: 69 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Build'
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
GCP_OIDC_PROVIDER_NAME: github-provider
GCP_PROJECT_ID: basemind-ai-development
GCP_PROJECT_NUMBER: 78794879644
GCP_SERVICE_ACCOUNT_NAME: github-actions
GCP_WORKLOAD_IDENTITY_POOL: dev-pool
GCP_REGION: europe-west3
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service:
- api-gateway
- dashboard-backend
- openai-connector
- frontend
include:
- file_path: ./docker/Dockerfile.go-services
service: api-gateway
- file_path: ./docker/Dockerfile.go-services
service: dashboard-backend
- file_path: ./docker/Dockerfile.ts-services
service: openai-connector
- file_path: ./docker/Dockerfile.frontend
service: frontend
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: projects/${{env.GCP_PROJECT_NUMBER}}/locations/global/workloadIdentityPools/${{env.GCP_WORKLOAD_IDENTITY_POOL}}/providers/${{env.GCP_OIDC_PROVIDER_NAME}}
service_account: ${{env.GCP_SERVICE_ACCOUNT_NAME}}@${{env.GCP_PROJECT_ID}}.iam.gserviceaccount.com
- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: ${{env.GCP_REGION}}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: ${{github.event_name == 'push' && startsWith(github.ref, 'refs/tags')}}
context: .
file: ${{matrix.file_path}}
build-args: |
BUILD_TARGET=${{matrix.service}}
tags: |
${{env.GCP_REGION}}-docker.pkg.dev/${{env.GCP_PROJECT_ID}}/basemind/${{matrix.service}}:latest
${{env.GCP_REGION}}-docker.pkg.dev/${{env.GCP_PROJECT_ID}}/basemind/${{matrix.service}}:${{github.sha}}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ jobs:
run: curl -sSf https://atlasgo.sh | sh
- name: Authenticate with GCP
id: auth
uses: google-github-actions/auth@v1.1.1
uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GCP_WORKLOAD_IDENTITY_POOL}/providers/${GCP_OIDC_PROVIDER_NAME}'
service_account: '${GCP_SERVICE_ACCOUNT_NAME}@${GCP_PROJECT_ID}.iam.gserviceaccount.com'
workload_identity_provider: projects/${{env.GCP_PROJECT_NUMBER}}/locations/global/workloadIdentityPools/${{env.GCP_WORKLOAD_IDENTITY_POOL}}/providers/${{env.GCP_OIDC_PROVIDER_NAME}}
service_account: ${{env.GCP_SERVICE_ACCOUNT_NAME}}@${{env.GCP_PROJECT_ID}}.iam.gserviceaccount.com
- name: Test
run: go test ./...
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Golang
uses: actions/setup-go@v4
with:
Expand Down
22 changes: 22 additions & 0 deletions .idea/jsonSchemas.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ services:
target: install
args:
BUILD_TARGET: openai-connector
NODE_ENV: development
PORT: 8000
ports:
- '8000:8000'
Expand All @@ -110,8 +109,6 @@ services:
dockerfile: docker/Dockerfile.frontend
context: .
target: install
args:
- NODE_ENV=development
ports:
- '3000:3000'
volumes:
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ RUN npm i -g pnpm

FROM base AS install
WORKDIR /app/
ARG NODE_ENV="production"
ENV NODE_ENV=${NODE_ENV}
COPY package.json pnpm-lock.yaml tsconfig.json .npmrc pnpm-workspace.yaml ./
COPY frontend/tsconfig.json frontend/package.json frontend/pnpm-lock.yaml frontend/next.config.js frontend/i18n.js frontend/postcss.config.js frontend/tailwind.config.js ./frontend/
COPY frontend/*.json frontend/*.js frontend/*.d.ts frontend/*.yaml ./frontend/
RUN pnpm install -r --ignore-scripts \
&& pnpm add -D @next/swc-linux-arm64-gnu @next/swc-linux-arm64-musl -w

Expand All @@ -31,8 +29,8 @@ COPY frontend/public frontend/public
COPY --from=build --chown=app:nodejs /app/frontend/dist frontend/dist

COPY package.json pnpm-lock.yaml .npmrc pnpm-workspace.yaml ./
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/next.config.js frontend/next-i18next.config.js frontend/tailwind.config.js ./frontend/
RUN pnpm install -r --ignore-scripts
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/next.config.js frontend/i18n.js frontend/tailwind.config.js ./frontend/
RUN pnpm install -r --prod

WORKDIR /app/frontend
USER app
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.ts-services
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ RUN npm i -g pnpm
FROM base AS install
WORKDIR /app/
ARG BUILD_TARGET
ARG NODE_ENV="production"
ENV NODE_ENV=${NODE_ENV}
COPY package.json pnpm-lock.yaml tsconfig.json .npmrc pnpm-workspace.yaml ./
COPY services/${BUILD_TARGET}/tsconfig* services/${BUILD_TARGET}/package.json services/${BUILD_TARGET}/webpack.config.ts ./services/${BUILD_TARGET}/
RUN pnpm install -r --ignore-scripts
Expand Down
Loading