From 42c157b91c42ccb724c8264aa482e056dc1fe781 Mon Sep 17 00:00:00 2001 From: vasgat Date: Fri, 22 Nov 2024 15:30:23 +0100 Subject: [PATCH 1/2] update workflow to build image only when updates occur on dist or docker folders --- .github/workflows/docker-build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 7e2d8a4..ba46e05 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -5,6 +5,7 @@ on: branches: [ main, staging ] paths: - 'dist/**' + - 'docker/**' jobs: build-and-push-image: From 2b700d9f950b92d18b6fe8d59941e64e06db0199 Mon Sep 17 00:00:00 2001 From: vasgat Date: Fri, 22 Nov 2024 15:33:33 +0100 Subject: [PATCH 2/2] Improve Dockerfile and nginx.conf to enhance Angular app deployment stability --- docker/dockerfile | 3 +++ nginx.conf | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 nginx.conf diff --git a/docker/dockerfile b/docker/dockerfile index 0584ae7..c1ed51a 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -4,6 +4,9 @@ FROM nginx:latest # Copy your static site files to the Nginx default directory COPY ../dist/apparel-top100-showcase /usr/share/nginx/html +# Copy custom Nginx configuration +COPY nginx.conf /etc/nginx/nginx.conf + # Expose port 80 to allow traffic EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b302955 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,29 @@ +worker_processes 1; + +events { worker_connections 1024; } + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + + # Serve Angular routes correctly + location / { + try_files $uri $uri/ /index.html; + } + + # Optional: Cache static files + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + try_files $uri =404; + expires 1M; + add_header Cache-Control "public"; + } + } +} \ No newline at end of file