Skip to content

Commit

Permalink
Fixed docker file react app
Browse files Browse the repository at this point in the history
  • Loading branch information
popovycholeg committed Sep 4, 2023
1 parent b8ec89b commit e075914
Show file tree
Hide file tree
Showing 7 changed files with 17,797 additions and 23 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ __pycache__/
/authentication/migrations/
/profiles/migrations/
/FrontEnd/node_modules
/FrontEnd/package-lock.json
6 changes: 3 additions & 3 deletions FrontEnd/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
npm-debug.log
**/node_modules
**/npm-debug.log
build
.git
*.md
.gitignore
.gitignore
31 changes: 20 additions & 11 deletions FrontEnd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
FROM node:14
WORKDIR ./
COPY ["package*.json","./"]
COPY **/package-lock.json ./
FROM node:16-alpine as builder
# Set the working directory to /app inside the container
WORKDIR /app
# Copy app files
COPY . .
RUN npm install
RUN npm install validator
RUN npm i react-router-dom@6.4.1
RUN npm install react-cookie
RUN npm install react-hook-form
EXPOSE 3000
CMD ["npm", "start"]
# Install dependencies (npm ci makes sure the exact versions in the lockfile gets installed)
RUN npm ci
# Build the app
RUN npm run build

# Bundle static assets with nginx
FROM nginx:1.21.0-alpine as production
ENV NODE_ENV production
# Copy built assets from `builder` image
COPY --from=builder /app/build /usr/share/nginx/html
# Add your nginx.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
15 changes: 7 additions & 8 deletions FrontEnd/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
version: node:14 AS development
version: "3.8"

services:
frontend:
app:
container_name: frontend
build: .
image: frontend
ports:
- 3000:3000
stdin_open: true
environment:
- CHOKIDAR_USEPOLLING=true
command: npm start
- 80:80
build:
context: .
target: production
9 changes: 9 additions & 0 deletions FrontEnd/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;

location / {
root /usr/share/nginx/html/;
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html;
}
}
Loading

0 comments on commit e075914

Please sign in to comment.