-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PIMS-633 Dockerize react-app (#2053)
Co-authored-by: GrahamS-Quartech <112989452+GrahamS-Quartech@users.noreply.github.com>
- Loading branch information
1 parent
e100eac
commit 337d085
Showing
3 changed files
with
92 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
############################################# | ||
# Base Build # | ||
############################################# | ||
FROM node:18.17.1-bullseye-slim as base | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Copy files | ||
COPY ./src ./src | ||
COPY package.json . | ||
COPY tsconfig.json . | ||
COPY vite.config.ts . | ||
COPY ./index.html . | ||
|
||
# Npm install packages. Omits dev dependencies when NODE_ENV=production | ||
RUN npm set progress=false | ||
RUN npm i | ||
|
||
# Build the project. | ||
RUN npm run build | ||
|
||
############################################# | ||
# NGINX Build # | ||
############################################# | ||
## Stage 2: Nginx state for serving content | ||
FROM nginx:alpine-slim as prod | ||
|
||
# copy custom nginx configuration from host to container | ||
COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Set working directory to nginx asset directory | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Remove default nginx static assets | ||
RUN rm -rf ./* | ||
|
||
# Copy static assets from builder stage | ||
COPY --from=base /app/dist . | ||
|
||
# Provide nginx directory the required permissions | ||
RUN chmod g+rwx /var/cache/nginx /var/run /var/log/nginx | ||
|
||
# Run nginx with global directives and daemon off | ||
ENTRYPOINT ["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,10 @@ | ||
server { | ||
listen 3000; | ||
location / { | ||
root /usr/share/nginx/html; | ||
try_files $uri /index.html; | ||
} | ||
location /api/ { | ||
proxy_pass "http://express-api:5000/"; | ||
} | ||
} |