Skip to content

Commit

Permalink
Fix Docker image build and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
au2001 committed Dec 25, 2023
1 parent 204b1cd commit 1c39a4d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
42 changes: 39 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
FROM node
FROM node:20-alpine AS base

FROM base AS deps
WORKDIR /app

RUN apk add --no-cache libc6-compat

COPY package*.json ./
RUN npm ci

COPY ./ ./
FROM base AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN npm run build

CMD npm start
FROM base 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

RUN mkdir .next
RUN chown nextjs:nodejs .next

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

USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["node", "server.js"]
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ version: "3"
services:
redis:
image: redis
command:
- redis-server
- --save
- "60"
- "1"
- --loglevel
- warning
ports:
- 6379:6379
volumes:
- redis-data:/data

app:
build: .
Expand All @@ -15,3 +24,6 @@ services:
SPOTIFY_CLIENT_SECRET: $SPOTIFY_CLIENT_SECRET
ports:
- 3000:3000

volumes:
redis-data:
4 changes: 3 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
output: "standalone",
};

module.exports = nextConfig;
Binary file added public/favicon.ico
Binary file not shown.
2 changes: 0 additions & 2 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use server";

import styles from "./page.module.css";
import { redirect } from "next/navigation";
import { exchangeAccessToken } from "@/utils/auth";
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use server";

import { getQueue } from "@/utils/queue";
import styles from "./page.module.css";
import { redirect } from "next/navigation";
Expand Down Expand Up @@ -31,3 +29,5 @@ export default async function Home() {
</main>
);
}

export const dynamic = "force-dynamic";

0 comments on commit 1c39a4d

Please sign in to comment.