Skip to content

Commit

Permalink
fix: update build (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkonush authored Dec 1, 2024
1 parent 3532c13 commit c926354
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 109 deletions.
30 changes: 2 additions & 28 deletions .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,8 @@ jobs:
run:
working-directory: services/ecran
steps:
- uses: actions/checkout@v4

- name: Restore cache
uses: actions/cache/restore@v4
id: cache
with:
path: |
services/ecran/node_modules
services/ecran/.next/cache
key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }}

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Build
run: bun run build

- name: Save cache
uses: actions/cache/save@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
services/ecran/node_modules
services/ecran/.next/cache
key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }}
- name: Checkout
uses: actions/checkout@v4

- name: Login to Container Registry
uses: docker/login-action@v3
Expand Down
59 changes: 30 additions & 29 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,41 @@ concurrency:
cancel-in-progress: true

jobs:
build:
build-ecran:
runs-on: arc-arm64
defaults:
run:
working-directory: services/ecran
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Restore cache
uses: actions/cache/restore@v4
id: cache
- name: Login to Container Registry
uses: docker/login-action@v3
with:
path: |
services/ecran/node_modules
services/ecran/.next/cache
key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }}

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Build
run: bun run build
registry: kalmyk.duckdns.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}

- name: Save cache
uses: actions/cache/save@v4
if: steps.cache.outputs.cache-hit != 'true'
- name: Build and push ecran
uses: docker/build-push-action@v6
with:
path: |
services/ecran/node_modules
services/ecran/.next/cache
key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }}
push: true
context: services/ecran
file: services/ecran/Dockerfile
platforms: linux/arm64
tags: kalmyk.duckdns.org/lab/ecran:latest
cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran:latest
cache-to: type=inline

build-worker:
runs-on: arc-arm64
defaults:
run:
working-directory: services/ecran
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Container Registry
uses: docker/login-action@v3
Expand All @@ -53,13 +54,13 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}

- name: Package into Docker image
- name: Build and push worker
uses: docker/build-push-action@v6
with:
push: true
context: services/ecran
file: services/ecran/Dockerfile.package
file: services/ecran/Dockerfile.worker
platforms: linux/arm64
tags: kalmyk.duckdns.org/lab/ecran:latest
cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran:latest
tags: kalmyk.duckdns.org/lab/ecran-worker:latest
cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran-worker:latest
cache-to: type=inline
Binary file removed bun.lockb
Binary file not shown.
36 changes: 17 additions & 19 deletions services/ecran/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
FROM oven/bun:1 as base
FROM base AS deps
FROM oven/bun:latest AS deps
WORKDIR /app
COPY package.json ./
COPY .npmrc ./
COPY package.json bun.lockb .npmrc ./
RUN bun install --frozen-lockfile

RUN bun install

# Rebuild the source code only when needed
FROM base AS builder
FROM node:lts-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm run build
RUN npm run build

# Production image, copy all the files and run next
FROM node:lts-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

# Set the correct permission for prerender cache
RUN chown -R nextjs:nodejs .next

RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public

USER nextjs

EXPOSE 3000

ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

CMD ["node", "server.js"]
22 changes: 0 additions & 22 deletions services/ecran/Dockerfile.package

This file was deleted.

17 changes: 7 additions & 10 deletions services/ecran/Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
FROM node:lts-slim AS deps
FROM oven/bun:latest AS deps
WORKDIR /app

RUN npm install -g pnpm
COPY package.json ./
COPY .npmrc ./
RUN pnpm install
COPY package.json bun.lockb .npmrc ./
RUN bun install

FROM node:lts-slim AS builder
WORKDIR /app
RUN npm install -g pnpm
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm run build:workflow
RUN npm run build:workflow

FROM node:lts-slim
FROM node:lts-slim AS runner
WORKDIR /app
RUN npm install -g pnpm && pnpm install esbuild-loader
RUN npm install esbuild-loader
COPY --from=builder /app .

CMD ["pnpm", "run", "start:worker"]
CMD ["npm", "run", "start:worker"]
Binary file modified services/ecran/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion services/ecran/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
"drizzle-orm": "0.36.4",
"esbuild": "0.24.0",
"esbuild-loader": "4.2.2",
"framer-motion": "12.0.0-alpha.2",
"highlight.js": "11.10.0",
"immer": "10.1.1",
"logrocket": "9.0.0",
"lucide-react": "0.462.0",
"monaco-editor": "0.52.0",
"framer-motion": "12.0.0-alpha.2",
"next": "15.0.3",
"next-auth": "5.0.0-beta.25",
"next-mdx-remote": "5.0.0",
Expand Down

0 comments on commit c926354

Please sign in to comment.