Skip to content

Commit

Permalink
added a Dockerfile
Browse files Browse the repository at this point in the history
and modified the project such that it does work
  • Loading branch information
surt91 committed Dec 8, 2021
1 parent a3fdd40 commit 5349673
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target/
.git/
example.png

Dockerfile
.dockerignore
docker-compose.yml
17 changes: 8 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ version = "0.1.0"
authors = ["Hendrik Schawe <surt91gmail.com>"]

[dependencies]
rand = "*"
clap = "*"
rayon = "*"
rand = "0.4"
clap = "2.24"
rayon = "0.8"

piston = "*"
pistoncore-glutin_window = "*"
pistoncore-sdl2_window = "*"
piston2d-graphics = "*"
piston2d-opengl_graphics = "*"
piston = "0.32"
pistoncore-glutin_window = "0.38"
piston2d-graphics = "0.21"
piston2d-opengl_graphics = "0.46"

fps_counter = "*"
fps_counter = "0.2"
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM rust:1.56 as builder
WORKDIR /usr/src/vicsek
COPY . .
RUN cargo build --release

FROM debian:bullseye-slim
# FIXME: there is not really a qt5 dependency, but this pulls in everything we need
# and I did not yet figure out what exactly we do need
RUN apt-get update && apt-get install -y libqt5gui5 && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/src/vicsek/target/release/vicsek /usr/local/bin/vicsek
ENTRYPOINT ["vicsek"]
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vicsek
------
# Vicsek :bird::bird::bird:

This is an implementation of a (modified) [Vicsek model](https://doi.org/10.1103/PhysRevLett.75.1226)
for flocking behavior.
Expand All @@ -8,3 +7,21 @@ for flocking behavior.

It is implemented in Rust and will show an OpenGL animation. Via command line
argument one can create a .mp4 using `gnuplot` and `ffmpeg`.

Just start it with `cargo`, (you can get it at, eg., [rustup.rs](https://rustup.rs/)):

```bash
cargo run --release
```

## :whale: Docker

If you are running Linux and have an X server installed (if you do not know what
this means, it is probably true; XWayland does also work), you can also use the provided docker container:

```bash
docker-compose build
# this is needed to allow access to your X-server from within the Docker container
xhost +local:
docker-compose up
```
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"

services:
app:
build: .
environment:
- DISPLAY=${DISPLAY}
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
network_mode: host
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/animate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate piston;
extern crate graphics;
extern crate glutin_window;
extern crate sdl2_window;
extern crate opengl_graphics;
extern crate fps_counter;
extern crate rand;
Expand All @@ -10,7 +9,7 @@ use std::cmp::min;
use std::f64::consts::PI;

use self::graphics::*;
use self::sdl2_window::Sdl2Window as Window;
use self::glutin_window::GlutinWindow as Window;
use self::piston::window::WindowSettings;
use self::piston::input::keyboard::Key::*;

Expand Down Expand Up @@ -78,6 +77,8 @@ pub fn show(size: (u32, u32), vicsek: &mut Vicsek) {
let mut window: Window = WindowSettings::new("Vicsek", [size.0, size.1])
.samples(4)
.exit_on_esc(true)
.decorated(false)
.srgb(false)
.build()
.unwrap();

Expand Down

0 comments on commit 5349673

Please sign in to comment.