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

Add Dockerfile for engine, batcher, and SDK images #353

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# NOTE: unlike .gitignore, ** is not implied, and only the root .dockerignore is considered.

# Dockerignore exclusive
/.dockerignore
/Dockerfile
/docker-tag
/.git

# .gitignore
/**/node_modules
/**/bin
/**/.nx
/**/dist
/**/build
/**/*.tsbuildinfo
/**/*.log
/**/.idea

# .husky/_/.gitignore
/.husky/_

# packages/batcher/batcher-standalone/.gitignore
/packages/batcher/batcher-standalone/packaged

# packages/contracts/evm-contracts/.gitignore
/packages/contracts/evm-contracts/artifacts
/packages/contracts/evm-contracts/build
/packages/contracts/evm-contracts/cache
/packages/contracts/evm-contracts/publish
/packages/contracts/evm-contracts/typechain-types

# packages/engine/paima-standalone/.gitignore
/packages/engine/paima-standalone/packaged

# packages/paima-sdk/paima-utils/.gitignore
/packages/paima-sdk/paima-utils/src/contract-types/
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# -----------------------------------------------------------------------------
FROM --platform=linux/amd64 alpine:3.18.6 AS build
RUN apk add --no-cache \
gcompat \
bash \
npm

# Installing a newer npm helps avert timeouts somehow.
RUN npm install -g npm@10.5.1

# Install "forge" binary from https://github.com/foundry-rs/foundry
# Just picked a popular tag.
COPY --link --from=ghcr.io/foundry-rs/foundry:nightly-de33b6af53005037b463318d2628b5cfcaf39916 \
/usr/local/bin /usr/local/bin

# Speed up build by caching node_modules separately.
WORKDIR /src
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run release:bin

# -----------------------------------------------------------------------------
# paima-SDK node_modules substitute
FROM scratch AS paima-sdk
COPY --link --from=build /src/packages/paima-sdk/paima-concise /node_modules/@paima/concise
COPY --link --from=build /src/packages/paima-sdk/paima-crypto /node_modules/@paima/crypto
COPY --link --from=build /src/packages/paima-sdk/paima-executors /node_modules/@paima/executors
COPY --link --from=build /src/packages/paima-sdk/paima-mw-core /node_modules/@paima/mw-core
COPY --link --from=build /src/packages/paima-sdk/paima-prando /node_modules/@paima/prando
COPY --link --from=build /src/packages/paima-sdk/paima-providers /node_modules/@paima/providers
COPY --link --from=build /src/packages/paima-sdk/paima-utils /node_modules/@paima/utils
COPY --link --from=build /src/packages/paima-sdk/paima-sdk/build /node_modules/@paima/sdk
COPY --link --from=build /src/packages/node-sdk/paima-db /node_modules/@paima/db
COPY --link --from=build /src/packages/build-utils/paima-build-utils /node_modules/@paima/build-utils
COPY --link --from=build /src/packages/node-sdk/paima-utils-backend /node_modules/@paima/utils-backend
COPY --link --from=build /src/packages/node-sdk/publish-wrapper/build /node_modules/@paima/node-sdk
COPY --link --from=build /src/packages/contracts/evm-contracts/ /node_modules/@paima/evm-contracts

# -----------------------------------------------------------------------------
# paima-batcher binary
FROM --platform=linux/amd64 alpine:3.18.6 AS paima-batcher
RUN apk add --no-cache \
gcompat \
libstdc++
COPY --link --from=build \
/src/packages/batcher/batcher-standalone/packaged/@standalone/batcher-bin/paima-batcher-linux \
/usr/local/bin/paima-batcher
#COPY --from=build \
# /src/packages/batcher/batcher-standalone/packaged/@standalone/batcher/db/migrations/up.sql \
# /init.sql
ENTRYPOINT [ "/usr/local/bin/paima-batcher" ]

# -----------------------------------------------------------------------------
# paima-engine binary, defaults to "run" subcommand
FROM --platform=linux/amd64 alpine:3.18.6 AS paima-engine
RUN apk add --no-cache \
gcompat \
libstdc++
COPY --link --from=build \
/src/bin/paima-engine-linux \
/usr/local/bin/paima-engine
WORKDIR "/paima"
ENTRYPOINT [ "/usr/local/bin/paima-engine" ]
CMD [ "run" ]
# Per https://docs.paimastudios.com/home/releasing-a-game/generate-build, user
# supplies packaged/gameCode.cjs, packaged/endpoints.cjs, and .env.$NETWORK
6 changes: 6 additions & 0 deletions docker-tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
version=${1:-latest}
docker buildx build . --target paima-sdk --tag ghcr.io/paimastudios/paima-sdk:"$version"
docker buildx build . --target paima-engine --tag ghcr.io/paimastudios/paima-engine:"$version"
docker buildx build . --target paima-batcher --tag ghcr.io/paimastudios/paima-batcher:"$version"