Next.js Discord

Discord Forum

Anyone ever figured out how to Dockerize nx apps?

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Avatar
Asiatic LionOP
I'm trying to just do a simple server and build of an app using docker, but it keeps error

"commands": {
    "docker-serve": {
      "command": "docker build -f apps/test-app/Dockerfile . -t test-app"
    },
    "docker-run": {
      "command": "docker run -p 4200:4200 test-app"
    },
}

# Start with the base Node.js image
FROM node:18-alpine

# Set the working directory
WORKDIR /app

# Install pnpm and necessary packages
RUN apk add --no-cache libc6-compat \
    && npm install -g pnpm nx

# Copy the root-level pnpm-lock.yaml and package.json to the WORKDIR
COPY pnpm-lock.yaml package.json ./

# Install all dependencies, including devDependencies
RUN pnpm install --frozen-lockfile --recursive

# Copy all other source code files
COPY . .

# Set the working directory to your specific app's directory
WORKDIR /app/apps/test-app

# Expose the port the app runs on
EXPOSE 4200

# Start the app
CMD ["nx", "serve", "test-app"]


and to my config I've added

output: 'standalone',

0 Replies