-
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.
feat(#90): Corrigindo Dockerfile docker-compose e adicionando nginx
Corrigindo dockerfile, docker compose e adicionando nginx para executar o front Co-authored-by: Ana-Luiza-SC <ssoares.analuiza@gmail.com>
- Loading branch information
1 parent
1344588
commit 0696b23
Showing
3 changed files
with
72 additions
and
33 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 |
---|---|---|
@@ -1,20 +1,40 @@ | ||
# Usa uma imagem oficial do Node.js como base | ||
FROM node:18-alpine | ||
# Build Stage | ||
FROM node:latest as build-stage | ||
|
||
# Define o diretório de trabalho dentro do container | ||
WORKDIR /app | ||
|
||
# Copia os arquivos do projeto para o container | ||
COPY package.json package-lock.json ./ | ||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Instala as dependências | ||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copia o restante do código do projeto | ||
# Copy the rest of the application files to the working directory | ||
COPY . . | ||
|
||
# Expõe a porta padrão do React | ||
EXPOSE 3000 | ||
# Build the React application | ||
RUN npm run build | ||
|
||
# Comando para iniciar a aplicação | ||
CMD ["npm", "start"] | ||
# Production Stage | ||
FROM nginx:latest | ||
|
||
# Copy the NGINX configuration file | ||
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
COPY --from=build-stage /app/build/ /usr/share/nginx/html | ||
|
||
# We need to make sure not to run the container as a non root user | ||
# for better security | ||
WORKDIR /app | ||
RUN chown -R nginx:nginx /app && chmod -R 755 /app && \ | ||
chown -R nginx:nginx /var/cache/nginx && \ | ||
chown -R nginx:nginx /var/log/nginx && \ | ||
chown -R nginx:nginx /etc/nginx/conf.d | ||
RUN touch /var/run/nginx.pid && \ | ||
chown -R nginx:nginx /var/run/nginx.pid | ||
|
||
USER nginx | ||
|
||
EXPOSE 80 | ||
|
||
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,19 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
|
||
location /health { | ||
return 200; | ||
} | ||
} |
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,25 +1,25 @@ | ||
services: | ||
backend: | ||
build: | ||
context: . | ||
dockerfile: server/Dockerfile | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- ./server:/app | ||
environment: | ||
- DB_NAME=YOUR_DB_NAME | ||
- DB_USER=YOUR_DB_USER | ||
- DB_PASSWORD=YOUR_DB_PASSWORD | ||
- DB_HOST=YOUR_DB_HOST | ||
build: | ||
context: . | ||
dockerfile: server/Dockerfile | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- ./server:/app | ||
environment: | ||
- DB_NAME=YOUR_DB_NAME | ||
- DB_USER=YOUR_DB_USER | ||
- DB_PASSWORD=YOUR_DB_PASSWORD | ||
- DB_HOST=YOUR_DB_HOST | ||
- DB_PORT=3306 | ||
|
||
frontend: | ||
build: | ||
context: . | ||
dockerfile: client/Dockerfile | ||
ports: | ||
- "3000:3000" | ||
volumes: | ||
- ./client:/app | ||
- /app/node_modules | ||
environment: | ||
- CHOKIDAR_USEPOLLING=true | ||
build: | ||
context: ./client | ||
dockerfile: Dockerfile | ||
container_name: frontend | ||
ports: | ||
- "3000:80" | ||
depends_on: | ||
- backend |