This commit is contained in:
parent
02556b6d62
commit
de5e8ab560
36
Dockerfile
36
Dockerfile
@ -1,38 +1,44 @@
|
|||||||
# Build stage
|
# Build stage
|
||||||
FROM node:20-slim as builder
|
FROM node:20-slim as base
|
||||||
|
|
||||||
ENV PNPM_HOME="/pnpm"
|
ENV PNPM_HOME="/pnpm"
|
||||||
ENV PATH="$PNPM_HOME:$PATH"
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
|
|
||||||
|
WORKDIR /base
|
||||||
WORKDIR /builder
|
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
||||||
|
# Development
|
||||||
|
FROM base AS dev
|
||||||
|
ENTRYPOINT []
|
||||||
|
CMD ["pnpm", "dev:next"]
|
||||||
|
|
||||||
|
|
||||||
|
# Production
|
||||||
|
FROM base AS builder
|
||||||
|
ENV NODE_ENV=production
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
# Production stage: serve the application
|
# Production: copy build artifacts
|
||||||
FROM node:20-slim as runner
|
FROM node:20-slim as runner
|
||||||
WORKDIR /runner
|
WORKDIR /prod
|
||||||
|
|
||||||
ENV PNPM_HOME="/pnpm"
|
ENV PNPM_HOME="/pnpm"
|
||||||
ENV PATH="$PNPM_HOME:$PATH"
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
|
|
||||||
## Copy build artifacts from the build stage
|
COPY --from=builder /base/package.json ./
|
||||||
COPY --from=builder /builder/package.json ./
|
COPY --from=builder /base/.next/standalone ./.next/standalone/
|
||||||
#COPY --from=builder /builder/node_modules ./node_modules
|
COPY --from=builder /base/.next/static ./.next/standalone/.next/static
|
||||||
COPY --from=builder /builder/.next/standalone ./.next/standalone/
|
COPY --from=builder /base/public ./.next/standalone/public
|
||||||
COPY --from=builder /builder/.next/static ./.next/standalone/.next/static
|
COPY --from=builder /base/next.config.mjs ./
|
||||||
COPY --from=builder /builder/public ./.next/standalone/public
|
|
||||||
COPY --from=builder /builder/next.config.mjs ./
|
|
||||||
|
|
||||||
FROM runner as server
|
# Production: serve the website
|
||||||
|
FROM runner as prod
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
@ -1,50 +1,48 @@
|
|||||||
|
---
|
||||||
services:
|
services:
|
||||||
nextjs:
|
nextjs:
|
||||||
image: git.autonomic.zone/autonomic-cooperative/nextload:latest
|
image: git.autonomic.zone/autonomic-cooperative/nextload-dev:latest
|
||||||
container_name: ${NAME}-nextjs
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# build:
|
build:
|
||||||
# context: payload
|
context: ./
|
||||||
# target: dev
|
target: dev
|
||||||
environment:
|
environment:
|
||||||
DEV: 1
|
- "NAME=${STACK_NAME}"
|
||||||
NAME: ${NAME}
|
- "PAYLOAD_SECRET=${PAYLOAD_SECRET}"
|
||||||
PAYLOAD_SECRET: ${PAYLOAD_SECRET}
|
- "MONGODB_USER=mongo"
|
||||||
NODE_ENV: development
|
- "MONGODB_HOST=${STACK_NAME}_mongo"
|
||||||
MONGODB_URI: "mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST:27017"
|
- "MONGODB_PORT=27017"
|
||||||
# volumes:
|
- "MONGODB_PASSWORD=${MONGO_PASSWORD}"
|
||||||
# - ./payload/src:/base/src
|
- "REPOSITORY"
|
||||||
# # - ./astro/src/types.ts:/types.ts
|
- "PORT=3000"
|
||||||
# - payload_media:/base/src/media
|
- "HOSTNAME=0.0.0.0"
|
||||||
|
- "MONGODB_URI=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@mongo:27017"
|
||||||
|
#volumes:
|
||||||
|
# Must be changed for dev as it is not standalone
|
||||||
|
#- payload_uploads:/runner/.next/standalone/.next/media
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
networks:
|
|
||||||
- front
|
|
||||||
- back
|
|
||||||
depends_on:
|
|
||||||
- mongo
|
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
container_name: ${NAME}-mongo
|
|
||||||
image: mongo:6.0.5
|
image: mongo:6.0.5
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
|
||||||
- 27017:27017
|
|
||||||
volumes:
|
volumes:
|
||||||
- mongo:/data/db
|
- mongo:/data/db
|
||||||
command:
|
command:
|
||||||
- --storageEngine=wiredTiger
|
- --storageEngine=wiredTiger
|
||||||
environment:
|
environment:
|
||||||
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER}
|
- "MONGO_INITDB_ROOT_USERNAME=mongo"
|
||||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
|
- "MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
- back
|
- internal
|
||||||
|
ports:
|
||||||
|
- 27017:27017
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
front:
|
internal:
|
||||||
back:
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mongo:
|
mongo:
|
||||||
payload_media:
|
payload_uploads:
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cross-env NODE_OPTIONS=--no-deprecation next dev",
|
"dev": "docker compose up",
|
||||||
|
"dev:next": "cross-env NODE_OPTIONS=--no-deprecation next dev",
|
||||||
"devturbo": "cross-env NODE_OPTIONS=--no-deprecation next dev --turbo",
|
"devturbo": "cross-env NODE_OPTIONS=--no-deprecation next dev --turbo",
|
||||||
"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
|
"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
|
||||||
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
|
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
|
||||||
|
Loading…
Reference in New Issue
Block a user