ggez / ggez

Rust library to create a Good Game Easily
http://ggez.rs
MIT License
4.24k stars 423 forks source link

Docker image for building GGEZ projects #274

Open blofroth opened 6 years ago

blofroth commented 6 years ago

Hi, I didn't know what the best you to let you know this is, so I thought I'd just post an issue. Let me know if there is a better way until next time :)

I had a Rust project using GGEZ in Bitbucket and noticed they added a Pipeline build feature which supports Rust. So naturally I wanted to try and build my project. However the official Rust Docker images don't have everything GGEZ needs, so I created a custom one: https://hub.docker.com/r/blofroth/rust-ggez-builder/

If I got everything right the "latest" tag should track latest Rust stable images automatically.

To use it in Bitbucket pipelines, add a file called "bitbucket-pipelines.yml" in the repo root:

image: blofroth/rust-ggez-builder:latest

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - cargo build -v
          - cargo test --all -v

Maybe you are all using other automated build solutions, but I guess more choice can't be bad :)

Edit: formatting for YAML config

observant2 commented 6 years ago

Sweet! Just a suggestion: In your dockerfile you should never use ":latest". Specify the latest version instead. For the same reason why you shouldn't use "*" in your cargo.toml. When a new version comes out with breaking changes, your image will automatically break. You don't want that.

I use docker a lot for web development, so another question: Can you execute your game inside docker?

observant2 commented 6 years ago

I think this is merely meant for building process and continuous integration. As soon as I set this up for gitlab.com I'll post my gitlab-ci.yml here. Maybe in two weeks or so.

blofroth commented 6 years ago

I would not normally use :latest, but here it seemed convenient to track latest stable rust, which I assume should be backwards compatible, and stable :). There are other tags to choose from though, like "1", which I guess is a little more future proof: https://hub.docker.com/r/library/rust/tags/

I could also set ut the Docker automatic build to rebuild on each update to the official image. Unless there is a better way I missed, it seems I otherwise would need to manually go in and update the Dockerfile in my git repo for each new version. I also now created a 1.23 tag instead, which uses the "rust:1.23" Docker images.

And you are right, I only use this for CI builds. There is no game per se yet for me, only some visualization and experiments with tiles. We'll see in 6 months maybe.

onelson commented 6 years ago

Can you execute your game inside docker?

I use a docker setup for doing gtk-rs work. It should be possible. Mostly I'd be interested in seeing if it'll be possible to have an image for producing static binaries, and potentially cross-compile for windows (might be a long shot).

onelson commented 6 years ago

I put together https://github.com/onelson/rust-project as a way to make it easier for folks at work to get going on rust projects with lots of native deps.

I've managed to adapt this a bit for ggez, and was able to launch the cube example in a container, but astroblasto fails on sound... I'll keep working at it, but I'm at least a little encouraged.

cube-in-a-container

Update: here's the setup thus far. https://github.com/onelson/ggez-project There are a bunch of question marks listed in the lower portion of the readme, but it's a start.

Generally, I think the part of the workflow that docker would fit best into will be cross-building rather than the active development process, so I'll take a look at that in the weeks to come. Still, having a docker setup to capture your native dependencies is the exact reason I started using this sort of project skeleton so maybe it's still a worthwhile pursuit.