Skip to content

Commit

Permalink
42 docker image zrobic (#91)
Browse files Browse the repository at this point in the history
* FEATURE: nginx z potrzbenymi rzeczami, zmiana api ze stalego na relatywne url

* FEATURE: dodanie workflow an pushowanie obrazu
  • Loading branch information
Janek1010 authored Jun 19, 2024
1 parent 0a0009d commit 35b973a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 7 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/angular-waytogo:latest
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nginx:latest


ENV API_URL http://localhost:8090/api


ADD dist/way-to-go-front-end /usr/share/nginx/html/

ADD docker/etc/nginx/templates/ /etc/nginx/templates/

EXPOSE 80
13 changes: 7 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumWarning": "600kb",
"maximumError": "700kb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
"maximumWarning": "200kb",
"maximumError": "250kb"
}
],
]
,
"outputHashing": "all"
},
"development": {
Expand All @@ -67,7 +68,7 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {

"proxyConfig": "src/proxy.conf.json"
},
"configurations": {
"production": {
Expand Down
18 changes: 18 additions & 0 deletions docker/etc/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen 80;
server_name localhost;

location /api {
proxy_pass ${API_URL}; # Use service name from Docker Compose
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location / {
root /usr/share/nginx/html/browser;
index index.html;
try_files $uri $uri/ /index.html;
}
}
2 changes: 1 addition & 1 deletion src/app/shared/http.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const maxPageSize = 2147483647;
export const defaultPageSize = 16;
export const backendUrl = 'http://localhost:8090/api/v1'
export const backendUrl = '/api/v1'
7 changes: 7 additions & 0 deletions src/proxy.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"/api": {
"target": "http://localhost:8090",
"secure": false,
"changeOrigin": true
}
}

0 comments on commit 35b973a

Please sign in to comment.