Skip to content

Docker- Build a Docker Image and Upload it as an artifact #1056

@Alex-is-Gonzalez

Description

@Alex-is-Gonzalez

Description

What it does: Builds a Docker image from your Dockerfile, saves it to a .tar.gz, and uploads it as an artifact you can download from the workflow run.

Step-by-step

  1. Add .github/workflows/docker-build-artifact.yml.
name: Format with Prettier

on:
  workflow_dispatch:
  pull_request:
    types: [opened, synchronize]

jobs:
  prettier:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout (full)
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18'

      - name: Install dependencies
        run: |
          npm ci || npm install
          npm install --no-save prettier

      - name: Run Prettier (format)
        run: npx prettier --write "**/*.{js,jsx,ts,tsx,json,md}"

      - name: Commit formatted changes
        uses: EndBug/add-and-commit@v9
        with:
          message: "chore: format code with Prettier"
          add: "."
  1. Make sure you have a Dockerfile at the repo root (or update the docker build path).

  2. Commit & push. After the run completes go to Actions → Build run → Artifacts and download my-app-image.

To load the image locally:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions