Skip to content

Commit

Permalink
feat: docker monorepo build (#1219)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Ingersoll <kingersoll@gmail.com>
Co-authored-by: alvarius <alvarius@lattice.xyz>
Co-authored-by: Will Cory <willcory10@gmail.com>
  • Loading branch information
4 people committed Sep 5, 2023
1 parent d52e7c7 commit 80a2641
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-paws-admire.md
@@ -0,0 +1,5 @@
---
"@latticexyz/services": patch
---

The build phase of services now works on machines with older protobuf compilers
13 changes: 13 additions & 0 deletions .dockerignore
@@ -0,0 +1,13 @@
node_modules
**/node_modules
.gitignore
*.md
dist
**/dist
**/out/
**/cache/
**/bindings/
**/artifacts/
**/abi/
**/broadcast/
**/deploys/
40 changes: 40 additions & 0 deletions Dockerfile
@@ -0,0 +1,40 @@
FROM docker.io/library/debian:bullseye-slim as base
ENV SHELL /bin/bash

WORKDIR /opt
RUN apt-get -y update --fix-missing && \
apt-get -y upgrade && \
apt-get install -y --no-install-recommends \
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

# foundry
RUN curl -L https://foundry.paradigm.xyz/ | bash && \
${HOME}/.foundry/bin/foundryup \
&& forge --version \
&& cast --version \
&& anvil --version \
&& chisel --version
# go
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
# pnpm
RUN npm install pnpm --global && pnpm --version

FROM base AS builder
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
WORKDIR /app/packages/store-indexer
EXPOSE 3001
15 changes: 10 additions & 5 deletions packages/services/Makefile
Expand Up @@ -29,27 +29,32 @@ protoc-ts:
--plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out ./protobuf/ts/ecs-stream \
--ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \
--proto_path proto proto/ecs-stream.proto
--proto_path proto proto/ecs-stream.proto \
--experimental_allow_proto3_optional
protoc \
--plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out ./protobuf/ts/ecs-snapshot \
--ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \
--proto_path proto proto/ecs-snapshot.proto
--proto_path proto proto/ecs-snapshot.proto \
--experimental_allow_proto3_optional
protoc \
--plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out ./protobuf/ts/ecs-relay \
--ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \
--proto_path proto proto/ecs-relay.proto
--proto_path proto proto/ecs-relay.proto \
--experimental_allow_proto3_optional
protoc \
--plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out ./protobuf/ts/faucet \
--ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \
--proto_path proto proto/faucet.proto
--proto_path proto proto/faucet.proto \
--experimental_allow_proto3_optional
protoc \
--plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out ./protobuf/ts/mode \
--ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \
--proto_path proto proto/mode.proto
--proto_path proto proto/mode.proto \
--experimental_allow_proto3_optional
.PHONY: protoc-ts

protoc-clean:
Expand Down

0 comments on commit 80a2641

Please sign in to comment.