Skip to content

Commit

Permalink
Add Dockerfile for engine, batcher, and SDK images
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceManiac committed Apr 22, 2024
1 parent df30db4 commit da595ee
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
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 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 [email protected]

# 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 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 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"

0 comments on commit da595ee

Please sign in to comment.