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