diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..16648c1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +# Build stage +FROM node:20-alpine AS builder + +WORKDIR /app + +# Install pnpm +RUN corepack enable && corepack prepare pnpm@latest --activate + +# Copy package files +COPY package.json pnpm-lock.yaml ./ + +# Install dependencies +RUN pnpm install --frozen-lockfile + +# Copy source code +COPY . . + +# Build the Next.js app +RUN pnpm build + +# Production stage +FROM node:20-alpine AS runner + +WORKDIR /app + +ENV NODE_ENV=production + +# Install pnpm +RUN corepack enable && corepack prepare pnpm@latest --activate + +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +# Copy built app +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..74b8e6d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +services: + jefflix: + build: . + restart: unless-stopped + labels: + - "traefik.enable=true" + - "traefik.http.routers.jefflix.rule=Host(`jefflix.lol`) || Host(`www.jefflix.lol`)" + - "traefik.http.services.jefflix.loadbalancer.server.port=3000" + networks: + - traefik-public + +networks: + traefik-public: + external: true diff --git a/next.config.mjs b/next.config.mjs index 5501ef9..c9403c6 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -6,7 +6,7 @@ const nextConfig = { images: { unoptimized: true, }, - + output: 'standalone', } export default nextConfig \ No newline at end of file