Skip to content

Commit

Permalink
Dockerize Nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
omfj committed Jan 28, 2025
1 parent 4667432 commit 0d904b1
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 59 deletions.
38 changes: 38 additions & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM node:20.18.0-alpine AS base

RUN npm install -g [email protected]
RUN npm install -g [email protected]

FROM base AS builder

RUN apk update
RUN apk add --no-cache libc6-compat

WORKDIR /app
COPY . .
RUN turbo prune @echo-webkom/web --docker

FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY --from=builder /app/out/json/ .
RUN pnpm install

COPY --from=builder /app/out/full/ .

RUN pnpm turbo build --filter=@echo-webkom/web...

FROM base AS runner
WORKDIR /app

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public

CMD node apps/web/server.js
30 changes: 30 additions & 0 deletions apps/web/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
app = "fly-echo-web"
primary_region = "arn"
kill_signal = "SIGINT"
kill_timeout = 5

[[services]]
internal_port = 3000
processes = [ "app" ]
protocol = "tcp"
auto_stop_machines = "stop"
auto_start_machines = true
min_machines_running = 1
script_checks = [ ]

# [services.concurrency]
# hard_limit = 120
# soft_limit = 100
# type = "requests"

[[services.ports]]
handlers = [ "http" ]
port = 80
force_https = true

[[services.ports]]
handlers = [ "tls", "http" ]
port = 443

[[vm]]
size = "shared-cpu-4x"
2 changes: 2 additions & 0 deletions apps/web/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { NextConfig } from "next";

const config = {
output: "standalone",

transpilePackages: [
"@echo-webkom/db",
"@echo-webkom/lib",
Expand Down
2 changes: 0 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
"@sanity/image-url": "1.1.0",
"@tanstack/react-query": "5.65.1",
"@types/remove-markdown": "0.3.4",
"@vercel/analytics": "1.3.2",
"@vercel/speed-insights": "1.0.14",
"calendar-link": "2.7.0",
"class-variance-authority": "0.7.0",
"clsx": "2.1.1",
Expand Down
5 changes: 0 additions & 5 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
Unna,
VT323,
} from "next/font/google";
import { Analytics } from "@vercel/analytics/react";
import { SpeedInsights } from "@vercel/speed-insights/next";
import NextTopLoader from "nextjs-toploader";

import { EasterEgg } from "@/components/easter-egg";
Expand Down Expand Up @@ -166,9 +164,6 @@ export default function RootLayout({ children }: RootLayoutProps) {
<FeedbackBlob />
<TailwindIndicator />
<EasterEgg />

<Analytics />
<SpeedInsights />
{/* </ThemeWrapper> */}
</Providers>
</body>
Expand Down
52 changes: 0 additions & 52 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d904b1

Please sign in to comment.