From 026534c1da79b155f0fd7dd204a9bed204537670 Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Fri, 3 Jan 2025 11:00:44 -0500 Subject: [PATCH] Add storybook docker --- .github/workflows/docker.yml | 48 ++++++++++++++++++++++++++++++++++++ Dockerfile.storybook | 33 +++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile.storybook diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..0807102be --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,48 @@ +on: + push: + branches: + - main + paths: + - "Dockerfile.storybook" + pull_request: + paths: + - "Dockerfile.storybook" + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/storybook-env + +jobs: + storybook-build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha,format=long + type=ref,event=branch + type=ref,event=pr + type=raw,value=latest,enable={{is_default_branch}} + + - uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.storybook + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile.storybook b/Dockerfile.storybook new file mode 100644 index 000000000..ff3dfafa8 --- /dev/null +++ b/Dockerfile.storybook @@ -0,0 +1,33 @@ +FROM mcr.microsoft.com/playwright:v1.49.1 + +# Set environment variables +ENV CI=true \ + TZ=UTC \ + DISPLAY=:99 + +# Install additional dependencies +RUN apt-get update && \ + apt-get install -y \ + curl \ + build-essential \ + jq \ + && rm -rf /var/lib/apt/lists/* + +# Install Rust and wasm-pack +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + . $HOME/.cargo/env && \ + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + +# Add cargo to PATH +ENV PATH="/root/.cargo/bin:${PATH}" + +# Install pnpm +RUN corepack enable pnpm + +# Setup display with consistent resolution +RUN Xvfb :99 -screen 0 1280x1024x24 2>/dev/null & + +WORKDIR /app + +# Default command that can be overridden +CMD ["bash"]