-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2367bf1
commit beedd69
Showing
11 changed files
with
243 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.git | ||
.gitignore | ||
*.md | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Starting with Node.js 18 Alpine for a lightweight image | ||
FROM node:20-alpine AS client | ||
|
||
# Enable Corepack to use PNPM | ||
RUN corepack enable | ||
|
||
# Set the working directory in the Docker container | ||
WORKDIR /app | ||
|
||
# Copy the necessary files to install dependencies | ||
# Including the pnpm-lock.yaml at the root to respect monorepo dependency resolutions | ||
COPY pnpm-lock.yaml* ./ | ||
COPY package.json ./ | ||
|
||
# Copy the entire monorepo to properly resolve internal dependencies like `types` | ||
# Note: This might include more than necessary for just the client build, but it ensures | ||
# that pnpm can correctly link local packages. Adjustments may be needed based on your exact structure. | ||
COPY . . | ||
|
||
# Install dependencies using PNPM, ensuring to work within the context of a monorepo | ||
RUN pnpm install --frozen-lockfile | ||
|
||
|
||
# Copying the rest of the client application files might not be necessary if you've already copied the entire monorepo | ||
# However, if you adjust to be more selective in what you copy to the Docker context (for efficiency), | ||
# ensure all necessary files for your client application are copied here. | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line to disable telemetry during runtime | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
# The port that your Next.js app will run on (default is 3000) | ||
EXPOSE 3000 | ||
|
||
# Start the Next.js development server | ||
CMD ["pnpm", "dev-client"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Start with Node.js 20 Alpine for a lightweight image | ||
FROM node:20-alpine AS client | ||
|
||
# Set the working directory in the Docker container | ||
WORKDIR /app | ||
|
||
# Enable Corepack to use PNPM | ||
RUN corepack enable | ||
|
||
# Copy the pnpm lock file and other necessary files for dependency installation | ||
COPY pnpm-lock.yaml* package.json ./ | ||
|
||
# Copy the entire monorepo to properly resolve internal dependencies | ||
COPY . . | ||
|
||
# Install dependencies using PNPM | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Add ARG directives for environment variables | ||
ARG NEXT_PUBLIC_GAME_SOCKET_SERVER | ||
ARG NEXT_PUBLIC_GAME_SERVER | ||
|
||
# Use the environment variables for the build | ||
ENV NEXT_PUBLIC_GAME_SOCKET_SERVER=$NEXT_PUBLIC_GAME_SOCKET_SERVER | ||
ENV NEXT_PUBLIC_GAME_SERVER=$NEXT_PUBLIC_GAME_SERVER | ||
|
||
# Build the Next.js application | ||
RUN pnpm build-client | ||
|
||
# The command to run your app in production mode | ||
CMD ["pnpm", "start-client"] | ||
|
||
# Expose the port your app runs on | ||
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: '3.8' | ||
services: | ||
server: | ||
build: | ||
context: . | ||
dockerfile: server/Dockerfile.prod | ||
ports: | ||
- "2567:2567" | ||
environment: | ||
- NODE_ENV=production | ||
# The client will probably be deployed on a Vercel server | ||
client: | ||
build: | ||
context: . | ||
dockerfile: client/Dockerfile.prod | ||
args: | ||
- NEXT_PUBLIC_GAME_SOCKET_SERVER=ws://localhost:2567 | ||
- NEXT_PUBLIC_GAME_SERVER=http://localhost:2567 | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- NODE_ENV=production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '3.8' | ||
services: | ||
server: | ||
build: | ||
context: . | ||
dockerfile: server/Dockerfile | ||
ports: | ||
- "2567:2567" | ||
volumes: | ||
- .:/app | ||
- /app/node_modules | ||
- /app/server/node_modules | ||
environment: | ||
- NODE_ENV=development | ||
client: | ||
build: | ||
context: . | ||
dockerfile: client/Dockerfile | ||
ports: | ||
- "3000:3000" | ||
volumes: | ||
- .:/app | ||
- /app/node_modules | ||
- /app/client/node_modules | ||
environment: | ||
- NODE_ENV=development | ||
- NEXT_PUBLIC_GAME_SOCKET_SERVER=ws://localhost:2567 | ||
- NEXT_PUBLIC_GAME_SERVER=http://localhost:2567 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Base image with Node.js and PNPM | ||
FROM node:20-slim AS server | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
# Install OpenSSL | ||
RUN apt-get update -y && apt-get install -y openssl libssl-dev | ||
|
||
# Copy the entire monorepo | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
# Install dependencies for the entire workspace | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
|
||
# Expose the port the server runs on | ||
EXPOSE 2567 | ||
|
||
# Start the server using the pnpm start script | ||
CMD ["pnpm", "dev-server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Base image with Node.js and PNPM | ||
FROM node:20-slim AS server | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
# Install OpenSSL | ||
RUN apt-get update -y && apt-get install -y openssl libssl-dev | ||
|
||
# Copy the entire monorepo | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
# Install dependencies for the entire workspace | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
|
||
# Set the working directory to the server package | ||
WORKDIR /app/server | ||
|
||
# Expose the port the server runs on | ||
EXPOSE 2567 | ||
|
||
# Start the server using the pnpm start script | ||
CMD ["pnpm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters