From 30070c51fe84688fa7bec0ae79419a1d7d40cbe5 Mon Sep 17 00:00:00 2001 From: Arata Date: Mon, 4 Mar 2024 15:19:14 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=82=B9=E3=83=86=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E7=92=B0=E5=A2=83=E7=94=A8=E3=81=AE=E3=82=A4?= =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=82=B8=E3=82=92=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{docker.yml => docker-production.yml} | 2 +- .github/workflows/docker-staging.yml | 58 +++++++++++++++++++ Dockerfile => production.Dockerfile | 0 staging.Dockerfile | 15 +++++ 4 files changed, 74 insertions(+), 1 deletion(-) rename .github/workflows/{docker.yml => docker-production.yml} (98%) create mode 100644 .github/workflows/docker-staging.yml rename Dockerfile => production.Dockerfile (100%) create mode 100644 staging.Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker-production.yml similarity index 98% rename from .github/workflows/docker.yml rename to .github/workflows/docker-production.yml index 0bf5b1bc..4ad58873 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker-production.yml @@ -1,4 +1,4 @@ -name: docker +name: docker (production) on: push: diff --git a/.github/workflows/docker-staging.yml b/.github/workflows/docker-staging.yml new file mode 100644 index 00000000..cd92560b --- /dev/null +++ b/.github/workflows/docker-staging.yml @@ -0,0 +1,58 @@ +name: docker (staging) + +on: + push: + branches: + - main + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ghcr.io/twin-te/twinte-front + tag-custom: stg + tag-custom-only: true + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/Dockerfile b/production.Dockerfile similarity index 100% rename from Dockerfile rename to production.Dockerfile diff --git a/staging.Dockerfile b/staging.Dockerfile new file mode 100644 index 00000000..75d8d866 --- /dev/null +++ b/staging.Dockerfile @@ -0,0 +1,15 @@ +FROM node:16 AS builder +WORKDIR /app + +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +ENV VITE_APP_URL=https://app.dev.twinte.net +ENV VITE_API_URL=https://app.dev.twinte.net/api/v3 + +COPY . ./ +RUN yarn build:staging + +FROM nginx +COPY production_nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=builder /app/dist /usr/share/nginx/html