From 368c7dfa37c7291055341b0cf9c8ca76b8694d6d Mon Sep 17 00:00:00 2001 From: Shion Ichikawa Date: Sun, 14 Apr 2024 10:15:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9A=9A=20add=20resources=20for=20ngin?= =?UTF-8?q?x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/nginx/Dockerfile | 6 ++++++ docker/nginx/default.conf | 10 ++++++++++ docker/nginx/nginx.conf | 0 docker/nginx/www/.gitkeep | 0 4 files changed, 16 insertions(+) create mode 100644 docker/nginx/Dockerfile create mode 100644 docker/nginx/default.conf create mode 100644 docker/nginx/nginx.conf create mode 100644 docker/nginx/www/.gitkeep diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..dee415c --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx:1.25.3-alpine + +COPY default.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d/nginx.conf +COPY www /var/www +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..01455bb --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,10 @@ +server { + listen 80; + server_name _; + location /api { + proxy_pass http://localhost:8080; + } + location / { + proxy_pass http://localhost:3000; + } +} diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 0000000..e69de29 diff --git a/docker/nginx/www/.gitkeep b/docker/nginx/www/.gitkeep new file mode 100644 index 0000000..e69de29 From 1d277396d7aa50fda408b668712eecd8deca08e1 Mon Sep 17 00:00:00 2001 From: Shion Ichikawa Date: Sun, 14 Apr 2024 10:17:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20workflow=20for=20building=20ngi?= =?UTF-8?q?nx=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-nginx.yml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/deploy-nginx.yml diff --git a/.github/workflows/deploy-nginx.yml b/.github/workflows/deploy-nginx.yml new file mode 100644 index 0000000..469c0f6 --- /dev/null +++ b/.github/workflows/deploy-nginx.yml @@ -0,0 +1,44 @@ +name: Build&Push Nginx image to GAR +on: + push: + branches: + - main + paths: + - 'docker/nginx/**' + - '.github/workflows/deploy-nginx.yaml' +jobs: + build-and-deploy: + runs-on: ubuntu-latest + permissions: + contents: 'read' + id-token: 'write' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Google Cloud + id: auth + uses: google-github-actions/auth@v2 + with: + token_format: access_token + workload_identity_provider: 'projects/228944830644/locations/global/workloadIdentityPools/gh-pool/providers/provider-github' + service_account: 'gh-actions@lgtmgen-project.iam.gserviceaccount.com' + + - name: Authorize Docker + id: docker-auth + uses: docker/login-action@v3 + with: + username: 'oauth2accesstoken' + password: ${{ steps.auth.outputs.access_token }} + registry: asia-northeast1-docker.pkg.dev + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + tags: asia-northeast1-docker.pkg.dev/lgtmgen-project/dev-main/nginx:latest + file: ./docker/nginx/Dockerfile + context: ./docker/nginx