-
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.
Creating Docker files for dev and prod. Additional work is needed
- Loading branch information
1 parent
afd2c7d
commit 3a30d2b
Showing
14 changed files
with
230 additions
and
5 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,17 @@ | ||
node_modules | ||
dist | ||
.git | ||
Dockerfile | ||
.dockerignore | ||
.env | ||
coverage | ||
tests | ||
logs | ||
docker | ||
tools | ||
Dockerfile* | ||
README.md | ||
LICENSE | ||
.vscode | ||
.git | ||
.gitignore |
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,19 @@ | ||
FROM node:20.18.0-alpine | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package*.json ./ | ||
RUN npm install --legacy-peer-deps | ||
# RUN npm run build:api | ||
|
||
# Copy the project files | ||
COPY . . | ||
# RUN npx nx run api:build | ||
|
||
# Expose the Node.js server port | ||
EXPOSE 3333 | ||
|
||
# Start the server with nodemon for hot reloading | ||
CMD npx nx reset && npx nx run api:serve --configuration=development |
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,48 @@ | ||
# Stage 1: Build | ||
FROM node:20.18.0-alpine AS builder | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package*.json ./ | ||
RUN npm install --legacy-peer-deps | ||
|
||
# Copy the project files | ||
COPY . . | ||
RUN npx nx run api:build | ||
|
||
# Stage 2: Serve | ||
FROM node:18-alpine AS runtime | ||
|
||
WORKDIR /app | ||
|
||
# Copy the build from the previous stage | ||
COPY --from=builder /app/dist/apps/api ./dist | ||
COPY package*.json ./ | ||
|
||
# Install a lightweight HTTP server to serve the static files | ||
RUN npm install --legacy-peer-deps | ||
RUN npm install prune --legacy-peer-deps | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3333 | ||
|
||
# Serve the app in production mode | ||
CMD ["node", "dist/main.js"] | ||
|
||
|
||
|
||
|
||
|
||
# Expose the Node.js server port | ||
# EXPOSE 3001 | ||
|
||
# Start the server with nodemon for hot reloading | ||
# CMD ["npm", "start", "api"] | ||
|
||
# RUN npx nx run api:serve --configuration=production | ||
# CMD ["serve", "-s", "dist", "-l", "5000"] | ||
# CMD ["npm", "serve", "api"] | ||
# CMD npx nx reset && npx nx run api:serve --configuration=production | ||
# CMD ["serve", "-s", "dist", "-l", "3333"] |
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,20 @@ | ||
# Use an official Node.js image | ||
FROM alpine:3.20 | ||
|
||
ENV NODE_VERSION 20.18.0 | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package.json package-lock ./ | ||
RUN npm install | ||
|
||
# Copy the project files | ||
COPY . . | ||
|
||
# Expose the React development server port (3000) | ||
EXPOSE 3000 | ||
|
||
# Start the React app in development mode | ||
CMD ["npm", "nx", "serve", "web"] |
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,26 @@ | ||
# Use an official Node.js image | ||
FROM alpine:3.20 | ||
|
||
ENV NODE_VERSION 20.18.0 | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package.json package-lock ./ | ||
RUN npm install | ||
|
||
# Copy the project files | ||
COPY . . | ||
|
||
# Build the React app for production | ||
RUN yarn nx build web --prod | ||
|
||
# Install 'serve' to serve the built app | ||
RUN npm install -g serve | ||
|
||
# Expose the port to serve the static files | ||
EXPOSE 5000 | ||
|
||
# Serve the production build | ||
CMD ["serve", "-s", "dist/apps/web", "-l", "5000"] |
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,17 @@ | ||
FROM node:20.18.0-alpine | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package*.json ./ | ||
# COPY tools/scripts/postinstall.sh ./tools/scripts/postinstall.sh | ||
RUN npm install --legacy-peer-deps | ||
|
||
# Copy the project files | ||
COPY . . | ||
|
||
# Expose the React development server port (3000) | ||
EXPOSE 4200 | ||
|
||
CMD ["npx", "nx", "serve", "web-app"] |
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 @@ | ||
# Stage 1: Build | ||
FROM node:20.18.0-alpine AS builder | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package*.json ./ | ||
RUN npm install --legacy-peer-deps | ||
RUN npm install prune --legacy-peer-deps | ||
|
||
# Copy the project files | ||
COPY . . | ||
RUN npx nx run web-app:build | ||
|
||
# Stage 2: Serve | ||
FROM nginx:alpine AS production | ||
|
||
# WORKDIR /app | ||
|
||
# Copy the build from the previous stage | ||
COPY --from=builder /app/dist/apps/web-app /usr/share/nginx/html | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 80 | ||
|
||
# Serve the app in production mode | ||
CMD ["nginx", "-g", "daemon off;"] |
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,26 @@ | ||
services: | ||
web: | ||
build: | ||
context: . | ||
dockerfile: ./apps/web-app/Dockerfile.dev | ||
volumes: | ||
- .:/app | ||
- /app/node_modules | ||
ports: | ||
- '4200:4200' | ||
environment: | ||
- NODE_ENV=development | ||
depends_on: | ||
- api | ||
|
||
api: | ||
build: | ||
context: . | ||
dockerfile: ./apps/api/Dockerfile.dev | ||
volumes: | ||
- .:/app | ||
- /app/node_modules | ||
ports: | ||
- '3333:3333' | ||
environment: | ||
- NODE_ENV=development |
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,20 @@ | ||
services: | ||
web: | ||
build: | ||
context: . | ||
dockerfile: ./apps/web-app/Dockerfile.prod | ||
ports: | ||
- '4200:80' | ||
environment: | ||
- NODE_ENV=production | ||
depends_on: | ||
- api | ||
|
||
api: | ||
build: | ||
context: . | ||
dockerfile: ./apps/api/Dockerfile.prod | ||
ports: | ||
- '3333:3333' | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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