Skip to content

Commit f0bf22a

Browse files
0xBigBossbeezybarg
andauthored
dockerize next app (#476)
* CI Docker next-app build Build docker image & push added to package.json updated ci for docker build/push on PR merge updated tiltfile to build and run the next-app in docker if CI * Fix deps cache step * re-add postinstall * Re-add next-app ignore build * wip on docker setup with e2e * even better * tilting * lots of fixes * last tweaks * fix docker build action * try this way * fix tilt parsing args * fix dep issue in infra * wait longer for docker build * faster start up time for dockerized * log the env local setup * convert more things to docker * almost there * more lil fixes * fix resource deps * don't forget about NEXT_PUBLIC_URL; * fix bug * set interval minining to 2 seconds * remove old secret --------- Co-authored-by: Beezy <[email protected]>
1 parent 7ea14d9 commit f0bf22a

38 files changed

+1112
-673
lines changed

.dockerignore

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
*
2-
!package.json
3-
!.yarnrc.yml
4-
!.yarn/patches
5-
!.yarn/plugins
6-
!.yarn/releases
7-
!.yarn/sdks
8-
!.yarn/versions
9-
!yarn.lock
10-
!foundry.toml
11-
!remappings.txt
12-
!tsconfig.json
13-
!tsconfig.base.json
14-
!apps
15-
!packages
16-
!supabase/package.json
17-
!supabase/tsconfig.json
18-
!supabase/*.types.ts
191
# may be redundant but last thing we want is large dockerfiles. from here on out, it mostly mirrors the .gitignore
2+
**/Tiltfile
3+
**/**.tiltfile
4+
**/**.Tiltfile
5+
**/*.tsbuildinfo
206
**/dist
217
**/node_modules
228
**/out
239
**/.tamagui/*
2410
**/coverage
2511
**/.next
2612
**/.expo
27-
/build
13+
**/build
2814
**/test-results
2915
**/playwright-report
30-
.cache/
16+
**/.next
17+
**/.expo
18+
**/.auth
19+
**/.tamagui/*
20+
**/coverage
21+
**/.turbo
22+
**/.cache/
23+
**/out
24+
**/*.snap
3125
.auth/
3226

3327
*.log*
@@ -65,6 +59,11 @@ tmp
6559
.parcel-cache
6660

6761
# Foundry stuff
68-
cache/
69-
out/
70-
broadcast
62+
**/cache/
63+
**/out/
64+
**/var
65+
**/broadcast
66+
!**/broadcast/**/run-latest.json
67+
**/Dockerfile
68+
**/.dockerignore
69+
**/.tamagui

.env.development.docker

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CI=true
2+
DEBUG=api:*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Setup Docker Build Environment"
2+
description: "Set up Node.js, install Foundry, and set up Bun. Runs Yarn install run docker build"
3+
inputs:
4+
build-nextjs-docker:
5+
description: "Whether to build Next.js docker image"
6+
required: false
7+
default: "true"
8+
push-nextjs-docker-image:
9+
description: "Whether to push build to dockerhub"
10+
required: false
11+
default: "false"
12+
dockerhub_username:
13+
description: "Username to login to dockerhub"
14+
required: false
15+
dockerhub_password:
16+
description: "Password to login to dockerhub"
17+
required: false
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Use Node.js
22+
if: ${{ inputs.build-nextjs-docker == 'true' }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version-file: .node-version
26+
cache: "yarn"
27+
- name: Setup Bun
28+
if: ${{ inputs.build-nextjs-docker == 'true' }}
29+
uses: oven-sh/setup-bun@v1
30+
- name: Install Foundry
31+
if: ${{ inputs.build-nextjs-docker == 'true' }}
32+
uses: foundry-rs/foundry-toolchain@v1
33+
with:
34+
version: nightly
35+
- name: Yarn Install
36+
if: ${{ inputs.build-nextjs-docker == 'true' }}
37+
shell: bash
38+
run: yarn install --immutable
39+
- name: Build Next.js
40+
if: ${{ inputs.build-nextjs-docker == 'true' }}
41+
shell: bash
42+
run: |
43+
cp .env.local.template .env.local
44+
yarn web:docker:build
45+
rm .env.local
46+
- uses: docker/login-action@v3
47+
if: ${{ inputs.build-nextjs-docker == 'true' }} && ${{ inputs.push-nextjs-docker-image == 'true' }}
48+
with:
49+
username: ${{ inputs.dockerhub_username }}
50+
password: ${{ inputs.dockerhub_password }}
51+
- name: Push to dockerhub
52+
shell: bash
53+
if: ${{ inputs.build-nextjs-docker == 'true' }} && ${{ inputs.push-nextjs-docker-image == 'true' }}
54+
run: yarn web:docker:push

.github/workflows/build-docker.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Docker Build
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
branches:
7+
- 'releases/**'
8+
- 'dev'
9+
- 'main'
10+
jobs:
11+
if_merged:
12+
if: github.event.pull_request.merged == true
13+
runs-on: ubuntu-latest
14+
# needs: [cache-deps]
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
- name: Build & Push Docker Image for next-app
20+
uses: ./.github/actions/docker-build
21+
with:
22+
build-nextjs-docker: true
23+
push-nextjs-docker-image: true
24+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
dockerhub_password: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ jobs:
166166
sleep 1
167167
echo tilt is ready
168168
max_attempts=60
169-
wait_timeout=5
169+
wait_timeout=7
170170
for ((i=1; i<=max_attempts; i++)); do
171171
echo "Attempt $i: Waiting for tilt with timeout ${wait_timeout}s"
172172

.tiltignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ packages/playwright/playwright-report
44
**/cache
55
/broadcast/**/run-*.json
66
!/broadcast/**/run-latest.json
7+
**/coverage
8+
**/*.tsbuildinfo
9+
**/node_modules
10+
**/.turbo

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ brew "caddy" unless system "caddy version"
1515
brew "nss" unless system "type nss-policy-check"
1616
brew "sqlfluff" unless CI or system "sqlfluff --version"
1717
brew "postgresql@15" unless system "type pg_dump"
18+
brew "gnu-sed" unless system "gsed --version"

0 commit comments

Comments
 (0)