-
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
Showing
3 changed files
with
60 additions
and
0 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,18 @@ | ||
version: '3.8' | ||
|
||
services: | ||
api: | ||
build: | ||
context: ./api | ||
dockerfile: Dockerfile | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- NODE_ENV=production | ||
|
||
web: | ||
build: | ||
context: ./web | ||
dockerfile: Dockerfile | ||
ports: | ||
- "80:80" |
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,38 @@ | ||
# Build stage | ||
FROM node:18-alpine AS build | ||
|
||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json first to leverage Docker cache | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy remaining files | ||
COPY . . | ||
|
||
# Build the project | ||
RUN npm run build | ||
|
||
# Verify that the dist directory exists and contains files | ||
RUN ls -la /app/dist | ||
|
||
# Production stage | ||
FROM nginx:alpine | ||
|
||
# Remove default nginx website | ||
RUN rm -rf /usr/share/nginx/html/* | ||
|
||
# Copy the build output to the Nginx HTML directory | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
|
||
# Expose the default Nginx port | ||
EXPOSE 80 | ||
|
||
# Add a health check (optional) | ||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | ||
CMD curl -f http://localhost/ || exit 1 | ||
|
||
# Start Nginx | ||
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