Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: publish docker image #1398

Merged
merged 25 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker

on:
push:
branches:
- main
workflow_dispatch:

jobs:
docker:
name: Build and push image
runs-on: ubuntu-latest-16-cores
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: ghcr.io/latticexyz/mud
target: mud
- image: ghcr.io/latticexyz/store-indexer
target: store-indexer
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=match,pattern=@(.*),group=1
type=ref,event=branch
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
target: ${{ matrix.target }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
44 changes: 28 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,45 @@ RUN apt-get -y update --fix-missing && \
libssl-dev make cmake graphviz \
git pkg-config curl time rhash ca-certificates jq \
python3 python3-pip lsof ruby ruby-bundler git-restore-mtime xz-utils zstd unzip gnupg protobuf-compiler \
wget net-tools iptables iproute2 iputils-ping ed zlib1g-dev wabt && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs
wget net-tools iptables iproute2 iputils-ping ed zlib1g-dev wabt

# node.js
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y nodejs && \
node --version && \
npm --version

# foundry
RUN curl -L https://foundry.paradigm.xyz/ | bash && \
${HOME}/.foundry/bin/foundryup \
&& forge --version \
&& cast --version \
&& anvil --version \
&& chisel --version
# go
ENV PATH="${PATH}:/usr/local/go/bin"
RUN wget https://dl.google.com/go/go1.20.4.linux-amd64.tar.gz && \
# -C to move to given directory
tar -C /usr/local/ -xzf go1.20.4.linux-amd64.tar.gz
tar -C /usr/local/ -xzf go1.20.4.linux-amd64.tar.gz && \
go version

# foundry
ENV PATH="${PATH}:/root/.foundry/bin"
RUN curl -L https://foundry.paradigm.xyz/ | bash && \
${HOME}/.foundry/bin/foundryup && \
forge --version && \
cast --version && \
anvil --version && \
chisel --version

# pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="${PATH}:${PNPM_HOME}"
RUN npm install pnpm --global && pnpm --version

FROM base AS builder
FROM base AS mud
COPY . /app
WORKDIR /app

ENV PATH="${PATH}:/usr/local/go/bin"
ENV PATH="${PATH}:/root/.foundry/bin"
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run -r build

FROM builder AS store-indexer
FROM mud AS store-indexer
WORKDIR /app/packages/store-indexer
EXPOSE 3001
EXPOSE 3001