diff --git a/.github/workflows/docker-dev-release.yml b/.github/workflows/docker-dev-release.yml index b00d1823..f5e52c90 100644 --- a/.github/workflows/docker-dev-release.yml +++ b/.github/workflows/docker-dev-release.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: + os: [ ubuntu-latest ] apps: - watcher - guard @@ -21,11 +22,24 @@ jobs: with: fetch-depth: 0 + - name: Build dependencies + run: | + npm ci + npm run build --workspace packages/constants + npm run build --workspace packages/types + npm run build --workspace packages/utils + npm run build --workspace packages --if-present + - name: Move Config Files run: | mv docker/nginx.conf ./ mv docker/entrypoint.sh ./ + - name: Build App + run: | + cd ./apps/${{ matrix.apps }} + npm run build + - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index c6f2b8c3..5e197a58 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -9,6 +9,9 @@ jobs: name: Build and Push Docker Image permissions: write-all runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest ] steps: - name: Checkout the Code @@ -16,11 +19,32 @@ jobs: with: fetch-depth: 0 + - name: Build dependencies + run: | + npm ci + npm run build --workspace packages/constants + npm run build --workspace packages/types + npm run build --workspace packages/utils + npm run build --workspace packages --if-present + - name: Move Config Files run: | mv docker/nginx.conf ./ mv docker/entrypoint.sh ./ + - name: Build App + id: build-app + run: | + if [[ ${{ github.ref }} =~ ^refs/tags/watcher-app-* ]]; then + cd ./apps/watcher + npm run build + echo "appName=watcher" >> $GITHUB_OUTPUT + elif [[ ${{ github.ref }} =~ ^refs/tags/guard-app-* ]]; then + cd ./apps/guard + npm run build + echo "appName=guard" >> $GITHUB_OUTPUT + fi + - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: @@ -37,30 +61,21 @@ jobs: username: rosen-bridge password: ${{ secrets.GITHUB_TOKEN }} - - name: Check Tag - id: check-tag - run: | - if [[ ${{ github.ref }} =~ ^refs/tags/watcher-app-* ]]; then - echo "appName=watcher" >> $GITHUB_OUTPUT - elif [[ ${{ github.ref }} =~ ^refs/tags/guard-app-* ]]; then - echo "appName=guard" >> $GITHUB_OUTPUT - fi - - name: Docker Metadata action uses: docker/metadata-action@v5 - if: steps.check-tag.outputs.appName != null + if: steps.build-app.outputs.appName != null id: meta with: - images: ghcr.io/rosen-bridge/ui-${{ steps.check-tag.outputs.appName }} + images: ghcr.io/rosen-bridge/ui-${{ steps.build-app.outputs.appName }} tags: | type=match,pattern=\d.\d.\d - name: Build and push uses: docker/build-push-action@v4 - if: steps.check-tag.outputs.appName != null + if: steps.build-app.outputs.appName != null with: context: . platforms: ${{ vars.PLATFORM_LIST || 'linux/amd64' }} push: true tags: ${{ steps.meta.outputs.tags }} - target: ${{ steps.check-tag.outputs.appName }} + target: ${{ steps.build-app.outputs.appName }} diff --git a/Dockerfile b/Dockerfile index a2b084a7..a275edd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,8 @@ -FROM node:18.17.0 AS builder -WORKDIR /app -COPY package*.json .nvmrc .prettierrc ./ -COPY packages ./packages -RUN npm ci -RUN npm run build --workspace packages/constants -RUN npm run build --workspace packages/types -RUN npm run build --workspace packages/utils -RUN npm run build --workspace packages --if-present - -FROM builder AS watcher-builder -COPY apps/watcher ./apps/watcher -RUN npm ci -WORKDIR /app/apps/watcher -RUN npm run build - -FROM builder AS guard-builder -COPY apps/guard ./apps/guard -RUN npm ci -WORKDIR /app/apps/guard -RUN npm run build - FROM nginx:1.25 AS watcher LABEL maintainer="rosen-bridge team " LABEL description="Docker image for the front-end of watcher owned by rosen-bridge organization." LABEL org.label-schema.vcs-url="https://github.com/rosen-bridge/ui" -COPY --from=watcher-builder /app/apps/watcher/out/ /usr/share/nginx/html +COPY ./apps/watcher/out/ /usr/share/nginx/html COPY nginx.conf /etc/nginx/nginx.conf COPY entrypoint.sh ./ ENV SERVICE_NAME=service @@ -35,7 +13,7 @@ FROM nginx:1.25 AS guard LABEL maintainer="rosen-bridge team " LABEL description="Docker image for the front-end of guard owned by rosen-bridge organization." LABEL org.label-schema.vcs-url="https://github.com/rosen-bridge/ui" -COPY --from=guard-builder /app/apps/guard/out/ /usr/share/nginx/html +COPY ./apps/guard/out/ /usr/share/nginx/html COPY nginx.conf /etc/nginx/nginx.conf COPY entrypoint.sh ./ ENV SERVICE_NAME=service