diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 575d3fa..fecc1b6 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -9,14 +9,21 @@ inputs: required: false description: "Tag latest version" default: "false" + target: + required: false + description: "Docker stage to target" + default: "final" outputs: - version: - description: "The version for the image" - value: ${{ steps.meta.outputs.version }} image: description: "The Docker image" value: ${{ steps.image.outputs.image }} + version: + description: "The version for the image" + value: ${{ steps.meta.outputs.version }} + digest: + description: "The build digest for the image" + value: ${{ steps.build.outputs.digest }} tag: description: "Combines image and version to a valid image tag" value: ${{ steps.tag.outputs.tag }} @@ -76,25 +83,17 @@ runs: - name: Build Image id: build - uses: docker/bake-action@v4 - env: - DOCKER_TAG: ${{ steps.tag.outputs.tag }} + uses: docker/build-push-action@v6 with: - targets: app - load: true - - - name: Get image digest - id: digest - shell: bash - run: | - echo '${{ steps.build.outputs.metadata }}' > metadata.json - echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT - cat $GITHUB_OUTPUT - - - name: Save Docker Image to Tar - shell: bash - run: | - docker save -o /tmp/image.tar ${{ steps.tag.outputs.tag }} + platforms: linux/amd64 + # Inject metadata produced earlier + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} + # Output image to a local tar file to be uploaded + outputs: type=docker,dest=${{ steps.tar.outputs.path }} + # Target a specified stage + target: ${{ inputs.node_env }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -106,3 +105,9 @@ runs: retention-days: 1 compression-level: 9 overwrite: true + + - name: Load Docker image + shell: bash + run: | + # Load the Docker image + docker load -i /tmp/image.tar diff --git a/docker-compose.yml b/docker-compose.yml index 85f3477..5626c57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,6 @@ version: '3.8' services: app: image: ${DOCKER_TAG:-} - build: - context: . - args: - NODE_ENV: development volumes: - node_modules:/app/node_modules - dist:/app/dist