Create dev script
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
tobias 2024-06-20 10:37:21 +02:00
parent 02556b6d62
commit de5e8ab560
3 changed files with 51 additions and 46 deletions

View File

@ -1,38 +1,44 @@
# Build stage
FROM node:20-slim as builder
FROM node:20-slim as base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /builder
WORKDIR /base
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
ENV NODE_ENV=production
COPY . .
# Development
FROM base AS dev
ENTRYPOINT []
CMD ["pnpm", "dev:next"]
# Production
FROM base AS builder
ENV NODE_ENV=production
RUN pnpm build
# Production stage: serve the application
# Production: copy build artifacts
FROM node:20-slim as runner
WORKDIR /runner
WORKDIR /prod
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
## Copy build artifacts from the build stage
COPY --from=builder /builder/package.json ./
#COPY --from=builder /builder/node_modules ./node_modules
COPY --from=builder /builder/.next/standalone ./.next/standalone/
COPY --from=builder /builder/.next/static ./.next/standalone/.next/static
COPY --from=builder /builder/public ./.next/standalone/public
COPY --from=builder /builder/next.config.mjs ./
COPY --from=builder /base/package.json ./
COPY --from=builder /base/.next/standalone ./.next/standalone/
COPY --from=builder /base/.next/static ./.next/standalone/.next/static
COPY --from=builder /base/public ./.next/standalone/public
COPY --from=builder /base/next.config.mjs ./
FROM runner as server
# Production: serve the website
FROM runner as prod
EXPOSE 3000
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -1,50 +1,48 @@
---
services:
nextjs:
image: git.autonomic.zone/autonomic-cooperative/nextload:latest
container_name: ${NAME}-nextjs
image: git.autonomic.zone/autonomic-cooperative/nextload-dev:latest
restart: unless-stopped
# build:
# context: payload
# target: dev
build:
context: ./
target: dev
environment:
DEV: 1
NAME: ${NAME}
PAYLOAD_SECRET: ${PAYLOAD_SECRET}
NODE_ENV: development
MONGODB_URI: "mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST:27017"
# volumes:
# - ./payload/src:/base/src
# # - ./astro/src/types.ts:/types.ts
# - payload_media:/base/src/media
- "NAME=${STACK_NAME}"
- "PAYLOAD_SECRET=${PAYLOAD_SECRET}"
- "MONGODB_USER=mongo"
- "MONGODB_HOST=${STACK_NAME}_mongo"
- "MONGODB_PORT=27017"
- "MONGODB_PASSWORD=${MONGO_PASSWORD}"
- "REPOSITORY"
- "PORT=3000"
- "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:
- 3000:3000
networks:
- front
- back
depends_on:
- mongo
mongo:
container_name: ${NAME}-mongo
image: mongo:6.0.5
restart: unless-stopped
ports:
- 27017:27017
volumes:
- mongo:/data/db
command:
- --storageEngine=wiredTiger
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
- "MONGO_INITDB_ROOT_USERNAME=mongo"
- "MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}"
networks:
- back
- internal
ports:
- 27017:27017
networks:
front:
back:
internal:
volumes:
mongo:
payload_media:
payload_uploads:

View File

@ -4,7 +4,8 @@
"private": true,
"type": "module",
"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",
"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",