Skip to content

Commit

Permalink
nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
taichan03 committed Jan 15, 2024
1 parent 14fda68 commit ac68347
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 16 deletions.
3 changes: 3 additions & 0 deletions config/env/.env.prod.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_USER=set_me
POSTGRES_PASSWORD=set_me
POSTGRES_DB=balancer_prod
13 changes: 4 additions & 9 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.prod.db
- ./config/env/.env.prod.db
backend:
build:
context: ./server
Expand All @@ -18,16 +18,11 @@ services:
depends_on:
- db
frontend:
image: balancer-frontend
build:
context: frontend
dockerfile: Dockerfile
args:
- IMAGE_NAME=balancer-frontend
context: ./frontend
dockerfile: Dockerfile.prod
ports:
- "3000:3000"
environment:
- CHOKIDAR_USEPOLLING=true
- "3000:80"
depends_on:
- backend

Expand Down
19 changes: 19 additions & 0 deletions frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:18 as builder

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm ci --legacy-peer-deps

COPY . .

RUN npm run build

FROM nginx:latest

COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=builder /usr/src/app/build /usr/share/nginx/html

EXPOSE 80
10 changes: 10 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;
server_name backend;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
2 changes: 1 addition & 1 deletion frontend/src/components/Header/Chat.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
// import { Link } from "react-router-dom";
import "../../components/Header/Chat.css";
import "../../components/Header/chat.css";
import { useState, useEffect, useRef } from "react";

import axios from "axios";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useRef, useEffect, Fragment } from "react";
import accountLogo from "../../assets/account.svg";
import { Link, useNavigate } from "react-router-dom";
import LoginMenuDropDown from "./LoginMenuDropDown";
import "../../components/Header/Header.css";
import "../../components/Header/header.css";
import Chat from "./Chat";
import { FeatureMenuDropDown } from "./FeatureMenuDropDown";
import MdNavBar from "./MdNavBar";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/DrugSummary/DrugSummaryForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
// import { Link } from "react-router-dom";
import "../../components/Header/Chat.css";
import "../../components/Header/chat.css";
import { useState, useEffect, useRef } from "react";
import axios from "axios";
// import TypingAnimation from "./components/TypingAnimation.tsx";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Header from "../../components/Header/Header";
import Footer from "../../components/Footer/Footer";
import LoginMenuDropDown from "../../components/Header/LoginMenuDropDown";
import { connect } from "react-redux";
import { useAuth } from "./AuthHooks";
import { useAuth } from "./authHooks.ts";
import { RootState } from "../../services/actions/types";
import { useLocation } from "react-router-dom";

Expand Down
4 changes: 2 additions & 2 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: '../server/build', // Custom output directory
outDir: 'build', // Custom output directory
assetsDir: 'static',
},
plugins: [react()],
Expand All @@ -16,4 +16,4 @@ export default defineConfig({
strictPort: true,
port: 3000,
},
});
});
2 changes: 1 addition & 1 deletion server/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ RUN chown -R app:app $APP_HOME
USER app

# run entrypoint.prod.sh
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]

0 comments on commit ac68347

Please sign in to comment.