From 38eb98834a9ce18327b4963dbc3250cb9f9dda79 Mon Sep 17 00:00:00 2001 From: mpostelnicu Date: Wed, 15 Nov 2023 10:34:18 +0200 Subject: [PATCH 1/3] OCNANDI-10 use docker images --- .env | 2 +- .github/workflows/docker-image.yml | 2 -- docker-compose-dev.yml | 13 ++++++++++++- docker-compose.yml | 12 +++++++++--- nginx/Dockerfile | 2 ++ nginx/conf.d/default.conf | 10 ++++++++++ nginx/conf.d/gzip.conf | 11 +++++++++++ 7 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 nginx/Dockerfile create mode 100644 nginx/conf.d/default.conf create mode 100644 nginx/conf.d/gzip.conf diff --git a/.env b/.env index 7fb32de80..9492146f2 100644 --- a/.env +++ b/.env @@ -8,6 +8,6 @@ INFOBIP_KEY=452789534289 SMSGATEWAY_KEY=98459432897 SMTP_PORT=25 SMTP_HOST=host.docker.internal -SERVER_URL=http://localhost:8090 +SERVER_URL=http://localhost SPRING_DEVTOOLS_RESTART_ENABLED=false DISABLE_EMAIL_SENDING=false diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index cf9c1d65d..af152c5e2 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,8 +3,6 @@ name: Docker Image CI on: push: branches: [ "develop" ] - pull_request: - branches: [ "develop" ] jobs: diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 7fdf1dcc6..7c1ccadee 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -2,8 +2,19 @@ version: '3.8' services: + + web: + image: ocnandi/ocnandi-web:${TAG-local} + restart: 'no' + ports: + - "80:80" + build: + context: ./nginx + depends_on: + - app + app: - image: ocportal-nandi/admin/dev:${TAG-local} + image: ocnandi/ocnandi-app:${TAG-local} restart: 'no' extra_hosts: - "host.docker.internal:host-gateway" #required so docker connects to host interface (this is for sending emails) diff --git a/docker-compose.yml b/docker-compose.yml index 371960bbc..82c754e8a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,13 +2,19 @@ version: '3.8' services: + web: + image: harbor.dgstg.org/ocnandi/ocnandi-web:${TAG} + restart: always + ports: + - "80:80"ok + depends_on: + - app + app: - image: ocportal-nandi/admin/prod:${TAG-local} + image: harbor.dgstg.org/ocnandi/ocnandi-app:${TAG} restart: always extra_hosts: - "host.docker.internal:host-gateway" #required so docker connects to host interface (this is for sending emails) - build: - target: prod depends_on: - db - mongo diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 000000000..9f205c3cb --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx +COPY conf.d /etc/nginx/conf.d \ No newline at end of file diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100644 index 000000000..5df9c5d5e --- /dev/null +++ b/nginx/conf.d/default.conf @@ -0,0 +1,10 @@ +server { + proxy_read_timeout 10m; + location / { + proxy_set_header Host $http_host; + proxy_pass http://app:8090; + proxy_redirect http://app:8090/ $scheme://$server_name/; + client_max_body_size 16M; + } + listen 80; +} \ No newline at end of file diff --git a/nginx/conf.d/gzip.conf b/nginx/conf.d/gzip.conf new file mode 100644 index 000000000..3bd3478fd --- /dev/null +++ b/nginx/conf.d/gzip.conf @@ -0,0 +1,11 @@ +## Compression. +gzip on; +gzip_buffers 16 8k; +gzip_comp_level 1; +gzip_http_version 1.1; +gzip_min_length 10; +gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf; +gzip_vary on; +gzip_proxied any; # Compression for all requests. +## http://wiki.nginx.org/NginxHttpGzipModule#gzip_disable +gzip_disable msie6; From bb43f8a491fce3c36661abec2e4b9daca7f4ee70 Mon Sep 17 00:00:00 2001 From: Mihai Postelnicu Date: Wed, 15 Nov 2023 15:35:22 +0200 Subject: [PATCH 2/3] OCNANDI-10 github action to build and push to harbor --- .github/workflows/docker-image.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index af152c5e2..77a49a427 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,6 +11,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker compose build + - uses: docker/login-action@v1 + with: + registry: harbor.dgstg.org + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} + + - uses: actions/checkout@v3 + - name: BuildAndPushDockerImages + run: | + docker build ./ --target prod -t harbor.dgstg.org/ocnandi/ocnandi-app:develop + docker push harbor.dgstg.org/ocnandi/ocnandi-app:develop + docker build ./nginx -t harbor.dgstg.org/ocnandi/ocnandi-web:develop + docker push harbor.dgstg.org/ocnandi/ocnandi-web:develop \ No newline at end of file From 15a57340e077a58fe2b7a301185cb0e379079103 Mon Sep 17 00:00:00 2001 From: Mihai Postelnicu Date: Wed, 15 Nov 2023 15:38:00 +0200 Subject: [PATCH 3/3] OCNANDI-10 newline --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 77a49a427..4fd6a9603 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -23,4 +23,4 @@ jobs: docker build ./ --target prod -t harbor.dgstg.org/ocnandi/ocnandi-app:develop docker push harbor.dgstg.org/ocnandi/ocnandi-app:develop docker build ./nginx -t harbor.dgstg.org/ocnandi/ocnandi-web:develop - docker push harbor.dgstg.org/ocnandi/ocnandi-web:develop \ No newline at end of file + docker push harbor.dgstg.org/ocnandi/ocnandi-web:develop