Skip to content

Commit b7551b1

Browse files
committed
ci(frontend/v2): 👷 Add Dockerfile
1 parent 3541892 commit b7551b1

4 files changed

Lines changed: 59 additions & 47 deletions

File tree

.github/workflows/frontend.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Docker Publish Frontend
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main,frontend/v2]
66

77
jobs:
88
check:
@@ -30,26 +30,28 @@ jobs:
3030
with:
3131
fetch-depth: 3
3232
- name: Install turbo
33-
run: npm install -g turbo@2.4.4
33+
run: npm install -g turbo@^2
3434
- name: Login to Docker
3535
run: |
3636
echo "${{ github.token }}" | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin
3737
- name: Create env file
3838
run: |
3939
touch apps/frontend/.env
40-
echo KEYCLOAK_URL="https://auth.buildtheearth.net/realms/website" >> apps/frontend/.env
41-
echo KEYCLOAK_ID="frontend" >> .env
40+
echo NEXT_PUBLIC_KEYCLOAK_URL="https://auth.buildtheearth.net/realms/website" >> apps/frontend/.env
41+
echo NEXT_PUBLIC_KEYCLOAK_ID="frontend" >> .env
4242
echo KEYCLOAK_SECRET="${{ secrets.KEYCLOAK_SECRET }}" >> apps/frontend/.env
4343
echo NEXTAUTH_URL="https://buildtheearth.net" >> apps/frontend/.env
4444
echo NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}" >> apps/frontend/.env
4545
echo NEXT_PUBLIC_API_URL="https://api.buildtheearth.net/api/v1" >> apps/frontend/.env
46+
echo NEXT_PUBLIC_FRONTEND_URL="https://buildtheearth.net" >> apps/frontend/.env
47+
echo DATABASE_URL="${{ secrets.DATABASE_URL }}" >> apps/frontend/.env
4648
echo NEXT_PUBLIC_MAPBOX_TOKEN="${{ secrets.MAPBOX_TOKEN }}" >> apps/frontend/.env
4749
echo PORT=3000 >> apps/frontend/.env
4850
- name: Check env
4951
run: cat apps/frontend/.env
5052
- name: Build the Docker image
51-
run: docker build . --file apps/frontend/Dockerfile --tag ghcr.io/buildtheearth/website-frontend:$(git rev-parse --short HEAD) --tag ghcr.io/buildtheearth/website-frontend:latest
53+
run: docker build . --file apps/frontend/Dockerfile --tag ghcr.io/buildtheearth/website-frontend:v2-$(git rev-parse --short HEAD) --tag ghcr.io/buildtheearth/website-frontend:v2-latest
5254
- name: Docker push tag
53-
run: docker push ghcr.io/buildtheearth/website-frontend:$(git rev-parse --short HEAD)
55+
run: docker push ghcr.io/buildtheearth/website-frontend:v2-$(git rev-parse --short HEAD)
5456
- name: Docker push latest
55-
run: docker push ghcr.io/buildtheearth/website-frontend:latest
57+
run: docker push ghcr.io/buildtheearth/website-frontend:v2-latest

apps/frontend/Dockerfile

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,45 @@
1-
FROM node:21-alpine AS base
1+
FROM node:22-alpine AS base
2+
RUN corepack enable
23

34
FROM base AS builder
4-
RUN apk update
5-
RUN apk add --no-cache libc6-compat
5+
RUN apk update && apk add --no-cache libc6-compat openssl
66
WORKDIR /app
7-
8-
# Run turbo (will prune the lockfile to only include target dependencies)
9-
RUN yarn global add turbo@^2.1.1
107
COPY . .
11-
RUN turbo prune dashboard --docker
12-
13-
# Add lockfile and package.json's of isolated subworkspace
8+
RUN yarn dlx turbo@^2 prune frontend --docker
9+
# ---
1410
FROM base AS installer
15-
RUN apk update
16-
RUN apk add --no-cache libc6-compat
11+
RUN apk update && apk add --no-cache libc6-compat openssl
12+
RUN ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3
1713
WORKDIR /app
1814

19-
# First install the dependencies (as they change less often)
15+
2016
COPY --from=builder /app/out/json/ .
2117
RUN yarn install
22-
RUN yarn list postcss
2318

24-
# Build the project
2519
COPY --from=builder /app/out/full/ .
2620
COPY --from=builder /app/apps/frontend/.env ./apps/frontend/.env
27-
COPY --from=builder /app/apps/frontend/next.config.ts ./apps/frontend/next.config.ts
28-
COPY --from=builder /app/apps/frontend/postcss.config.cjs ./apps/frontend/postcss.config.cjs
29-
ENV NEXT_TELEMETRY_DISABLED 1
30-
31-
21+
COPY --from=builder /app/apps/frontend/.env ./packages/db/.env
3222
RUN yarn turbo run build --filter=frontend...
23+
RUN yarn install
3324

3425
FROM base AS runner
3526
WORKDIR /app
3627

37-
ENV NODE_ENV production
38-
ENV NEXT_TELEMETRY_DISABLED 1
39-
40-
# Create a runner user
41-
RUN addgroup --system --gid 1001 nodejs
42-
RUN adduser --system --uid 1001 nextjs
28+
ENV NODE_ENV=production
29+
ENV NEXT_TELEMETRY_DISABLED=1
30+
RUN addgroup --system --gid 1001 nodejs && \
31+
adduser --system --uid 1001 nextjs
4332
USER nextjs
4433

34+
# Don't run production as root for security reasons
35+
# Automatically leverage output traces to reduce image size
36+
# https://nextjs.org/docs/advanced-features/output-file-tracing
4537
# Reduce image size
46-
COPY --from=installer --chown=nextjs:nodejs /app/apps/dashboard/.next/standalone ./
47-
COPY --from=installer --chown=nextjs:nodejs /app/apps/dashboard/.next/static ./apps/dashboard/.next/static
48-
COPY --from=installer --chown=nextjs:nodejs /app/apps/dashboard/public ./apps/dashboard/public
38+
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/.next/standalone ./
39+
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/.next/static ./apps/frontend/.next/static
40+
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/public ./apps/frontend/public
4941

5042
EXPOSE 3000
51-
52-
ENV PORT 3000
53-
ENV HOSTNAME "0.0.0.0"
54-
55-
CMD node apps/dashboard/server.js
43+
ENV PORT=3000
44+
ENV HOSTNAME="0.0.0.0"
45+
CMD ["node", "apps/frontend/server.js"]

apps/frontend/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import './.next/types/routes.d.ts';
3+
import './.next/dev/types/routes.d.ts';
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

apps/frontend/src/app/[locale]/page.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import { Locale } from 'next-intl';
4141
import { getFormatter, getTranslations, setRequestLocale } from 'next-intl/server';
4242
import { Fragment } from 'react';
4343

44+
export const dynamic = 'force-static';
45+
4446
export default async function Page({ params }: { params: Promise<{ locale: Locale }> }) {
4547
const locale = (await params).locale;
4648
setRequestLocale(locale);
@@ -294,9 +296,15 @@ export default async function Page({ params }: { params: Promise<{ locale: Local
294296
<Title order={2}>{t('globalCommunity.title')}</Title>
295297
<div className="heading-underline" style={{ marginBottom: 'var(--mantine-spacing-md)' }} />
296298
<Text maw={{ base: '100%', xs: '85%' }}>{t('globalCommunity.description')}</Text>
297-
<Button variant="filled" color="buildtheearth" rightSection={<IconChevronRight size={12} />} mt="md">
299+
<LinkButton
300+
variant="filled"
301+
href="/get-started#build"
302+
color="buildtheearth"
303+
rightSection={<IconChevronRight size={12} />}
304+
mt="md"
305+
>
298306
{t('globalCommunity.cta')}
299-
</Button>
307+
</LinkButton>
300308
</Box>
301309
</GridCol>
302310
<GridCol
@@ -363,9 +371,15 @@ export default async function Page({ params }: { params: Promise<{ locale: Local
363371
<Title order={2}>{t('explore.title')}</Title>
364372
<div className="heading-underline" style={{ marginBottom: 'var(--mantine-spacing-md)' }} />
365373
<Text maw={{ base: '100%', xs: '85%' }}>{t('explore.description')}</Text>
366-
<Button variant="filled" color="buildtheearth" rightSection={<IconChevronRight size={12} />} mt="md">
374+
<LinkButton
375+
href="/get-started#explore"
376+
variant="filled"
377+
color="buildtheearth"
378+
rightSection={<IconChevronRight size={12} />}
379+
mt="md"
380+
>
367381
{t('explore.cta')}
368-
</Button>
382+
</LinkButton>
369383
</Box>
370384
</GridCol>
371385
</Grid>
@@ -410,9 +424,15 @@ export default async function Page({ params }: { params: Promise<{ locale: Local
410424
</CarouselSlide>
411425
))}
412426
</Carousel>
413-
<Button variant="filled" color="buildtheearth" rightSection={<IconChevronRight size={12} />} mt="md">
427+
<LinkButton
428+
href="/gallery"
429+
variant="filled"
430+
color="buildtheearth"
431+
rightSection={<IconChevronRight size={12} />}
432+
mt="md"
433+
>
414434
{t('gallery.cta')}
415-
</Button>
435+
</LinkButton>
416436
</GridCol>
417437
</Grid>
418438
<Grid

0 commit comments

Comments
 (0)