Context into tools: I'm using in the repo:
Turborepo (/)
Docker
NextJS
So I'm having trouble trying to figure out what I'm doing wrong with docker... When I run the project in dev mode everything's fine and all assets are clearly being served to the client as seen in the image below.
Running in yarn dev
mode
I can login to the app
As you can see above the apps completely fine and operational. But as soon as we go to docker I have setup the following
./docker-compose.yaml
services:
web:
container_name: client
env_file:
- ./apps/client/.env
build:
context: .
dockerfile: ./apps/client/Dockerfile
restart: always
ports:
- 3000:3000
networks:
- crosspost_docker_network
networks:
crosspost_docker_network:
external: true
apps/client/Dockerfile
FROM node:18-alpine AS base
# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
FROM base AS builder
# Check to understand why libc6-compat might be needed.
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune client --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN yarn install
# Build the project
COPY --from=builder /app/out/full/ .
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
COPY ./apps/client/.env /app/apps/client/.env
RUN yarn turbo build
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Automatically leverage output traces to reduce image size
#
COPY --from=installer --chown=nextjs:nodejs /app/apps/client/.next/standalone/apps/client .
COPY --from=installer --chown=nextjs:nodejs /app/apps/client/.next/standalone/node_modules node_modules
COPY --from=installer --chown=nextjs:nodejs /app/apps/client/public public
COPY --from=installer --chown=nextjs:nodejs /app/apps/client/.next/static public/_next/static
ENV HOSTNAME="0.0.0.0"
EXPOSE 3000
ENV PORT 3000
CMD node server.js
When running the above docker config Im greeted with the following
Site not working, missing css, chunks, static assets
So im really not sure at this point. I have made the repo public so that anyone can pull and take a look and it would be massively appreciated if you know why this is failing as it has been days and still no luck fixing.
Repo to clone
Everything is mentioned above in terms of things I've attempted