-
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
ad2f6da
commit cc71d8e
Showing
14 changed files
with
142 additions
and
127 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
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
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 |
---|---|---|
@@ -1,23 +1,2 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
node_modules | ||
build |
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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
# services/client/my-app/Dockerfile-dev2 | ||
# Use NGINX to serve the static files | ||
FROM nginx:1.15.8-alpine | ||
|
||
# Use the official Node.js image as the base image | ||
FROM node:14-alpine | ||
# Remove the default NGINX configuration | ||
RUN rm /etc/nginx/conf.d/default.conf | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/app | ||
# Copy the site-specific configuration file | ||
COPY prod.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Copy package.json and package-lock.json into the container | ||
COPY package*.json ./ | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Install dependencies | ||
RUN npm install | ||
COPY . /usr/share/nginx/html | ||
|
||
# Copy the rest of the application code into the container | ||
COPY . . | ||
# Copy the build output to the NGINX html directory | ||
# COPY /build /usr/share/nginx/html | ||
|
||
# Command to start the application | ||
CMD ["npm", "start"] | ||
# Expose port 80 to the outside world | ||
EXPOSE 80 | ||
|
||
# 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# services/nginx/nginx.conf | ||
|
||
worker_processes 1; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
# Include all config files from the conf.d directory | ||
include /etc/nginx/conf.d/*.conf; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
# services/nginx/prod.conf | ||
|
||
server { | ||
listen 80; | ||
|
||
server_name localhost; # Use localhost for local development | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location /api { | ||
proxy_pass http://backend:8000; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,40 @@ | ||
# Use an official Nginx image | ||
FROM nginx:latest | ||
# Stage 1: Build the React application | ||
FROM mhart/alpine-node:12 AS builder | ||
|
||
# Copy the Nginx configuration file | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
WORKDIR /usr/src/app | ||
|
||
# Remove the default Nginx configuration file | ||
ENV PATH /usr/src/app/node_modules/.bin:$PATH | ||
|
||
# Copy package.json and package-lock.json separately to leverage Docker cache | ||
COPY package.json /usr/src/app/package.json | ||
COPY package-lock.json /usr/src/app/package-lock.json | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the application files | ||
COPY . /usr/src/app | ||
|
||
# Build the application | ||
RUN npm run build --production | ||
|
||
# Stage 2: Serve the React application with NGINX | ||
FROM nginx:1.15.8-alpine | ||
|
||
# Remove the default NGINX configuration | ||
RUN rm /etc/nginx/conf.d/default.conf | ||
|
||
# Copy the custom NGINX configuration file | ||
COPY ./nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Copy the site-specific NGINX configuration file | ||
COPY ./services/nginx/prod.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Copy the build output to the NGINX html directory | ||
COPY --from=builder /usr/src/app/build /usr/share/nginx/html | ||
|
||
# Expose port 80 to the outside world | ||
EXPOSE 80 | ||
|
||
# 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,17 @@ | ||
# services/nginx/nginx.conf | ||
|
||
worker_processes 1; | ||
|
||
events { | ||
# Define any event-related settings here | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
resolver 127.0.0.11; # Use Docker's internal DNS resolver | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
access_log /var/log/nginx/access.log main; | ||
error_log /var/log/nginx/error.log warn; | ||
|
||
server { | ||
listen 80; | ||
|
||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
|
||
location / { | ||
proxy_pass http://localhost:8000; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location /api/ { | ||
proxy_pass http://backend:8000; # Ensure this matches the service name and port | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_connect_timeout 60s; | ||
proxy_send_timeout 60s; | ||
proxy_read_timeout 60s; | ||
send_timeout 60s; | ||
} | ||
|
||
location /static/ { | ||
alias /usr/share/nginx/html/static/; | ||
} | ||
|
||
gzip on; | ||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
types { | ||
application/font-woff2 woff2; | ||
application/font-woff woff; | ||
} | ||
} | ||
# Include all config files from the conf.d directory | ||
include /etc/nginx/conf.d/*.conf; | ||
} |
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
Oops, something went wrong.