Skip to content

Commit

Permalink
chore: enable frontend docker build (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher authored Dec 10, 2023
2 parents 79108eb + a4ca319 commit 8bfebf5
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 8 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Build (Frontend)'
on:
push:
branches:
- development
- production
paths:
- '.github/workflows/build-frontend.yaml'
- 'package.json'
- 'shared/ts/**'
- 'frontend/**'
env:
SERVICE_NAME: frontend
FILE_PATH: ./docker/Dockerfile.frontend
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
environment: ${{ github.ref_name }}
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@v2
with:
token_format: access_token
workload_identity_provider: projects/${{vars.GCP_PROJECT_NUMBER}}/locations/global/workloadIdentityPools/${{vars.GCP_WORKLOAD_IDENTITY_POOL}}/providers/${{vars.GCP_OIDC_PROVIDER_NAME}}
service_account: ${{vars.GCP_SERVICE_ACCOUNT_NAME}}@${{vars.GCP_PROJECT_ID}}.iam.gserviceaccount.com
- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: ${{vars.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: true
context: .
file: ${{env.FILE_PATH}}
build-args: |
BUILD_TARGET=${{env.SERVICE_NAME}}
SERVICE_NAME=${{env.SERVICE_NAME}}
tags: |
${{vars.GCP_REGION}}-docker.pkg.dev/${{vars.GCP_PROJECT_ID}}/basemind/${{env.SERVICE_NAME}}:latest
${{vars.GCP_REGION}}-docker.pkg.dev/${{vars.GCP_PROJECT_ID}}/basemind/${{env.SERVICE_NAME}}:${{github.sha}}
15 changes: 9 additions & 6 deletions docker/Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ RUN npm i -g pnpm
FROM base AS install
WORKDIR /app/
COPY package.json pnpm-lock.yaml tsconfig.json .npmrc pnpm-workspace.yaml ./
COPY frontend/*.* ./frontend/
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/tsconfig.json ./frontend/
RUN pnpm install -r --ignore-scripts \
&& pnpm add -D @next/swc-linux-arm64-gnu @next/swc-linux-arm64-musl -w
COPY frontend/next.config.js frontend/tailwind.config.ts ./frontend/

FROM install AS build
WORKDIR /app/
COPY shared/ts shared/ts
COPY shared/ts/src shared/ts/src
COPY frontend/src frontend/src
COPY frontend/public frontend/public
WORKDIR /app/frontend

WORKDIR /app/frontend/
RUN pnpm run build

FROM base AS app
Expand All @@ -25,10 +27,11 @@ RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 app

COPY frontend/public frontend/public
COPY --from=build --chown=app:nodejs /app/frontend/dist frontend/dist
COPY --from=build --chown=app:nodejs /app/frontend/dist /app/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/tailwind.config.js ./frontend/
COPY package.json pnpm-lock.yaml tsconfig.json .npmrc pnpm-workspace.yaml ./
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/tsconfig.json ./frontend/
COPY frontend/next.config.js frontend/tailwind.config.ts ./frontend/
RUN pnpm install -r --prod

WORKDIR /app/frontend
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/app/[locale]/privacy-policy/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import {
} from '@/components/legal-document-view';
import { Footer } from '@/components/static-site/footer';
import { StaticPageHeader } from '@/components/static-site/header';
import { TrackStaticPage } from '@/components/static-site/track-static-page';

export default function PrivacyPolicyPage() {
return (
<div className="w-screen bg-base-100">
<TrackStaticPage pageName="privacy-policy" />
<div className="container w-full mx-auto">
<header>
<StaticPageHeader />
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/static-site/cta-section.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import Link from 'next/link';
import { useTranslations } from 'next-intl';

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/static-site/features-section.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import Image from 'next/image';
import { useTranslations } from 'next-intl';

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/static-site/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import Link from 'next/link';
import { useTranslations } from 'next-intl';

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/static-site/header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import Link from 'next/link';
import { useTranslations } from 'next-intl';
import { ChevronRight } from 'react-bootstrap-icons';
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/static-site/intro-section.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import Image from 'next/image';
import Link from 'next/link';
import { useTranslations } from 'next-intl';
Expand Down
5 changes: 5 additions & 0 deletions monorepo.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="a2f7907c-dbf6-40dc-9f8a-cc5a27e7f56f" />
</component>
Expand Down

0 comments on commit 8bfebf5

Please sign in to comment.