Skip to content

Commit

Permalink
Merge pull request #24 from SAINIAbhishek/frontend_ngnix
Browse files Browse the repository at this point in the history
nginx configuration
  • Loading branch information
SAINIAbhishek authored Sep 3, 2024
2 parents 39d230d + 3106695 commit 463651d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ services:
args:
NODE_ENV: production
# This is the name we’ll use to refer to this image in Docker commands or to push to a Docker registry.
image: sainiabhishek/fullstack_task-frontend:1.1.0
image: sainiabhishek/fullstack_task-frontend:1.1.1
container_name: frontend
restart: always
environment:
Expand Down
3 changes: 3 additions & 0 deletions frontend/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ RUN rm -rf ./*
# Copy the built application from the build stage
COPY --from=build /app/dist .

# Copy the custom Nginx configuration to the Nginx configuration directory
COPY nginx.conf /etc/nginx/nginx.conf

# Expose the application port
EXPOSE 80

Expand Down
47 changes: 47 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Define the user and group for Nginx worker processes
user nginx;
worker_processes auto;

# Define paths for error and PID logs
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
worker_connections 1024; # Max connections per worker
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

# Configure the server block
server {
listen 80; # Listen on port 80 for HTTP requests
server_name localhost; # Server name for handling requests (typically used for virtual hosts)

root /usr/share/nginx/html; # Root directory for your static files

# Default file to serve when accessing the root directory
index index.html;

# Handle URL routing for Single Page Applications (SPA)
location / {
try_files $uri $uri/ /index.html; # Try to serve the requested file, or fallback to index.html
}

# Cache static assets to improve performance
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1d;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fullstack_tasks-frontend",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"type": "module",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), 'APP_PORT');

return {
base: './',
base: '/',
envPrefix: 'APP_',
plugins: [react()],
server: {
port: parseInt(env.APP_PORT),
strictPort: true,
historyApiFallback: true,
},
preview: {
port: parseInt(env.APP_PORT),
Expand Down

0 comments on commit 463651d

Please sign in to comment.