File tree 3 files changed +65
-5
lines changed
3 files changed +65
-5
lines changed Original file line number Diff line number Diff line change
1
+ name : Docker Build and Push
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ pull_request :
7
+ branches : [main]
8
+
9
+ jobs :
10
+ build :
11
+ runs-on : ubuntu-latest
12
+ permissions :
13
+ contents : read
14
+ packages : write
15
+
16
+ steps :
17
+ - name : Checkout repository
18
+ uses : actions/checkout@v4
19
+
20
+ - name : Set up Docker Buildx
21
+ uses : docker/setup-buildx-action@v3
22
+
23
+ - name : Login to GitHub Container Registry
24
+ if : github.event_name != 'pull_request'
25
+ uses : docker/login-action@v3
26
+ with :
27
+ registry : ghcr.io
28
+ username : ${{ github.actor }}
29
+ password : ${{ secrets.GITHUB_TOKEN }}
30
+
31
+ - name : Build and push Docker image
32
+ uses : docker/build-push-action@v5
33
+ with :
34
+ context : .
35
+ push : ${{ github.event_name != 'pull_request' }}
36
+ tags : |
37
+ ghcr.io/${{ github.repository }}:latest
38
+ ghcr.io/${{ github.repository }}:${{ github.sha }}
39
+ cache-from : type=gha
40
+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change 1
1
2
- FROM oven/bun:1.1.3-alpine
2
+ # Base image
3
+ FROM oven/bun:1.1.3-alpine AS builder
3
4
5
+ # Install build tools
4
6
RUN apk add --no-cache nodejs npm git
5
7
6
8
WORKDIR /app
7
9
10
+ # Install dependencies (separated for better cache utilization)
8
11
COPY package.json bun.lockb ./
9
12
RUN bun install
10
13
14
+ # Copy source code and build
11
15
COPY . .
12
-
13
16
RUN bun next telemetry disable
17
+ RUN bun run build
18
+
19
+ # Runtime stage
20
+ FROM oven/bun:1.1.3-alpine AS runner
21
+ WORKDIR /app
22
+
23
+ # Copy only necessary files from builder
24
+ COPY --from=builder /app/.next ./.next
25
+ COPY --from=builder /app/public ./public
26
+ COPY --from=builder /app/package.json ./package.json
27
+ COPY --from=builder /app/bun.lockb ./bun.lockb
28
+ COPY --from=builder /app/node_modules ./node_modules
14
29
30
+ # Start development server
15
31
CMD ["bun" , "dev" , "-H" , "0.0.0.0" ]
Original file line number Diff line number Diff line change 1
- # This is a Docker Compose file for setting up the morphic-stack environment.
1
+ # Docker Compose configuration for the morphic-stack development environment
2
2
3
3
name : morphic-stack
4
4
services :
5
5
morphic :
6
+ image : ghcr.io/${GITHUB_REPOSITORY:-your-username/morphic}:latest
6
7
build :
7
- context : . # The build context is the current directory
8
+ context : .
8
9
dockerfile : Dockerfile
9
- command : bun dev # Use `bun dev -H 0.0.0.0` to listen on all interfaces
10
+ cache_from :
11
+ - morphic:builder
12
+ - morphic:latest
13
+ command : bun dev -H 0.0.0.0
10
14
env_file : .env.local # Load environment variables
11
15
ports :
12
16
- ' 3000:3000' # Maps port 3000 on the host to port 3000 in the container.
You can’t perform that action at this time.
0 commit comments