diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bba196a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +node_modules +.dockerignore +.eslintrc.cjs +.gitignore +.git +dist +Dockerfile +README.md +test.txt diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..20a85ac --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,65 @@ +name: Build Docker images + +on: + release: + types: [published] + schedule: + - cron: "0 0 * * 0" + pull_request: + push: + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: "${{ github.repository_owner }}/bbmodules-frontend" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache docker layers + uses: actions/cache@v3 + id: cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Gather Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{version}}.{{major}} + labels: | + cache-from=type=local,src=/tmp/.buildx-cache + cache-to=type=local,dest=/tmp/.buildx-cache + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: ${{ github.event_name == 'release' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm/v7,linux/arm64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a494df5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20 AS builder +WORKDIR /build + +COPY package.json package-lock.json ./ +RUN npm i + +COPY . . +RUN npm run build + +FROM ghcr.io/thedevminertv/gostatic:1.2.2 +CMD ["--compress-level", "2", "--spa"] + +COPY --from=builder /build/dist /static