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

Conversation

SpaceManiac
Copy link
Contributor

@SpaceManiac SpaceManiac commented Apr 22, 2024

A bit of an experiment. The goal is to make it easier to version and deploy games, and to reduce accidental structural differences between dev, test, and production.

./docker-tag [tag] builds and tags the images with the given tag (ex: 2.3.0) or latest if not specified.

The intended use of the images are:

  • paima-engine serves as a base for game backend images:

    FROM ghcr.io/paimastudios/paima-engine:2.3.0 AS mygame-backend
    COPY --from=build-backend /src/packaged packaged
    ARG NETWORK=docker
    COPY .env.$NETWORK .env.$NETWORK
    COPY config.$NETWORK.yml config.$NETWORK.yml
    COPY extensions.$NETWORK.yml extensions.yml
    ENV NETWORK=$NETWORK
  • paima-batcher can be run directly, supplying just the configuration:

    docker run --env-file .env.docker ghcr.io/paimastudios/paima-batcher:2.3.0

    or included in a docker-compose file:

    batcher:
      image: ghcr.io/paimastudios/paima-batcher:2.3.0
      depends_on:
        - hardhat
        - backend
        - database
      env_file:
        - .env.docker
      ports:
        - "3340:3340"
  • paima-sdk can be used as a COPY source for a Docker build that needs a newer Node SDK than is on NPM:

    COPY --from=ghcr.io/paimastudios/paima-sdk:latest \
      /node_modules/@paima \
      node_modules/@paima

Caveats:

  • The paima-engine image is bigger than it needs to be because the binary includes the batcher, contracts, templates, so on. The image only really needs the run subcommand.
  • The old batcher and db docker-compose templates are still hanging around.
  • The paima-sdk image is a little goofy. An image of just free-hanging files is not really how Docker is meant to be used. But this seems like the easiest way to make compiled outputs of non-NPM-tagged versions available to downstream Docker builds.

Thoughts?

@acedward
Copy link
Contributor

I just tested it and failed for me, I had to add python3 g++ make to the Dockerfile

image image image

@SpaceManiac
Copy link
Contributor Author

SpaceManiac commented Apr 23, 2024

Interesting. I see "gyp info using [email protected] | linux | arm64" in the logs. I think since you're on an ARM Mac, it's building a Linux-for-arm image by default, while I'm on x86_64. We could set --platform linux/amd64 in either the docker-tag script or in the Dockerfile to override that default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants