Skip to content

Commit 3cfb9b0

Browse files
author
François Pelletier
committed
Merge remote-tracking branch 'origin/blond-maggots/francois' into blond-maggots/main
# Conflicts: # src/pages/index.tsx
2 parents 7373507 + d6a2898 commit 3cfb9b0

File tree

8 files changed

+59
-107
lines changed

8 files changed

+59
-107
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ module.exports = {
33
extends: [
44
"plugin:react/recommended",
55
"plugin:@typescript-eslint/recommended",
6+
"next/core-web-vitals",
67
],
78
rules: { "react/react-in-jsx-scope": "off" },
89
settings: {
910
react: {
1011
version: "detect",
1112
},
1213
},
13-
};
14+
};

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,5 @@ cython_debug/
165165
next-env.d.ts
166166
dist
167167

168-
coverage/
168+
coverage/
169+
/.env

Dockerfile

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
1-
# Stage 1: Build the application
1+
# Build stage
22
FROM node:20-alpine AS build
33

4-
# Set the working directory
54
WORKDIR /app
65

7-
# Copy package.json and package-lock.json
6+
# Copy package.json and package-lock.json (if available)
87
COPY package*.json ./
98

109
# Install dependencies
11-
RUN npm install
10+
RUN npm ci --only=production
1211

13-
# Copy the rest of the application code
14-
COPY . .
12+
# Copy only necessary files for the build
13+
COPY *.json ./
14+
COPY *.js ./
15+
COPY *.ts ./
16+
COPY cypress ./cypress
17+
COPY public ./public
18+
COPY src ./src
1519

1620
# Build the application
1721
RUN npm run build
1822

19-
# Stage 2: Serve the application
20-
FROM fholzer/nginx-brotli:v1.23.4
23+
# Production stage
24+
FROM nginx:alpine
2125

22-
# Copy nginx configuration file
23-
COPY nginx.conf /etc/nginx/nginx.conf
26+
# Remove default nginx static assets
27+
RUN rm -rf /usr/share/nginx/html/*
2428

2529
# Copy built files from the previous stage
26-
COPY --from=build /app/build /usr/share/nginx/html
30+
COPY --from=build /app/dist /usr/share/nginx/html
31+
32+
# Copy nginx configuration
33+
COPY nginx.conf /etc/nginx/nginx.conf
2734

2835
# Expose port 8080
2936
EXPOSE 8080
3037

3138
# Start nginx
32-
CMD ["nginx", "-g", "daemon off;"]
39+
CMD ["nginx", "-g", "daemon off;"]

cypress/support/commands.ts

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,4 @@
1-
/// <reference types="cypress" />
2-
// ***********************************************
3-
// This example commands.ts shows you how to
4-
// create various custom commands and overwrite
5-
// existing commands.
6-
//
7-
// For more comprehensive examples of custom
8-
// commands please read more here:
9-
// https://on.cypress.io/custom-commands
10-
// ***********************************************
11-
//
12-
//
13-
// -- This is a parent command --
14-
// Cypress.Commands.add('login', (email, password) => { ... })
15-
//
16-
//
17-
// -- This is a child command --
18-
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19-
//
20-
//
21-
// -- This is a dual command --
22-
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23-
//
24-
//
25-
// -- This will overwrite an existing command --
26-
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27-
//
28-
// declare global {
29-
// namespace Cypress {
30-
// interface Chainable {
31-
// login(email: string, password: string): Chainable<void>
32-
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33-
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34-
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35-
// }
36-
// }
37-
// }
1+
// Add your Cypress commands here
2+
3+
// Add this line at the end of the file
4+
export {};

docker-run-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
docker network create medical-codex-net
22
docker stop codex-website-app
33
docker rm codex-website-app
4-
docker run -p 8080:8080 --env-file=.env --network medical-codex-net --name codex-website-app codex-website-app
4+
docker run -p 8080:8080 --env-file=".env" --network medical-codex-net --name codex-website-app codex-website-app

next.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3+
reactStrictMode: true,
4+
output: 'export',
35
distDir: "./dist", // Changes the build output directory to `./dist/`.
6+
images: {
7+
unoptimized: true,
8+
},
9+
env: {
10+
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
11+
},
412
};
513

6-
module.exports = nextConfig;
14+
module.exports = nextConfig;

nginx.conf

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,32 @@
1-
user nginx;
2-
worker_processes 1;
3-
4-
error_log /var/log/nginx/error.log warn;
5-
pid /var/run/nginx.pid;
6-
71
events {
8-
worker_connections 1024;
2+
worker_connections 1024;
93
}
104

115
http {
12-
include /etc/nginx/mime.types;
13-
default_type application/octet-stream;
14-
15-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16-
'$status $body_bytes_sent "$http_referer" '
17-
'"$http_user_agent" "$http_x_forwarded_for"';
18-
19-
access_log /var/log/nginx/access.log main;
20-
21-
sendfile on;
22-
#tcp_nopush on;
23-
24-
keepalive_timeout 65;
25-
26-
gzip on;
27-
gzip_disable "msie6";
28-
29-
gzip_vary on;
30-
gzip_proxied any;
31-
gzip_comp_level 6;
32-
gzip_buffers 16 8k;
33-
gzip_http_version 1.1;
34-
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
35-
36-
brotli on;
37-
brotli_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
38-
brotli_static on;
39-
6+
types {
7+
text/html html htm shtml;
8+
text/css css;
9+
application/javascript js;
10+
# ... other types ...
11+
}
4012
server {
4113
listen 8080;
42-
14+
server_name localhost;
4315
root /usr/share/nginx/html;
4416
index index.html;
4517

46-
server_name localhost;
47-
48-
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
49-
expires -1;
18+
location / {
19+
try_files $uri $uri.html $uri/ =404;
5020
}
5121

52-
location ~* \.(?:css|js)$ {
53-
try_files $uri =404;
54-
expires 1y;
55-
access_log off;
56-
add_header Cache-Control "public";
22+
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
23+
expires max;
24+
log_not_found off;
5725
}
5826

59-
location ~ ^.+\..+$ {
60-
try_files $uri =404;
61-
}
62-
63-
location / {
64-
try_files $uri $uri/ /index.html;
27+
error_page 404 /404.html;
28+
location = /404.html {
29+
internal;
6530
}
6631
}
67-
}
32+
}

src/pages/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, FC } from "react";
1+
import React, { useState, FC, useEffect } from "react";
22
import SearchSection from "@/components/HomePage/SearchSection";
33
import ResultsSection from "@/components/HomePage/ResultsSection";
44
import TranslateSection from "@/components/HomePage/TranslateSection";
@@ -7,11 +7,14 @@ import handleTranslate from "@/utils/handleTranslate";
77
import HelpModal from "@/components/ui/modals/HelpModal";
88
import Head from "next/head";
99

10-
const NEXT_PUBLIC_API_URL: string | undefined = process.env.NEXT_PUBLIC_API_URL;
10+
const NEXT_PUBLIC_API_URL: string | undefined = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000' ;
1111

1212
const languages = ["English", "Ukrainian", "Russian", "French"];
1313

1414
const HomePage: FC = () => {
15+
useEffect(() => {
16+
console.log("API URL:", process.env.NEXT_PUBLIC_API_URL);
17+
}, []);
1518
const [inputSearch, setInputSearch] = useState<string>("");
1619
const [outputTranslation, setOutputTranslation] = useState<string>("");
1720
const [medicines, setMedicines] = useState<Array<{ matching_name: string }>>(

0 commit comments

Comments
 (0)