Merge pull request #1042 from f0rmiga/improve-docker-support

Improved Docker support
This commit is contained in:
Konrad Kuśnierz 2019-10-10 08:12:52 +02:00 committed by GitHub
commit f048b0e414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 93 additions and 56 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
/build/
Dockerfile

View File

@ -2,10 +2,34 @@ language: cpp
compiler: compiler:
- gcc - gcc
before_script: before_script:
- sudo apt-get install libboost-all-dev libphysfs-dev libssl-dev liblua5.1-dev libglew-dev libvorbis-dev libopenal-dev libz-dev -y - |-
set -o errexit
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
git-core \
libboost-all-dev \
libglew-dev \
liblua5.1-0-dev \
libncurses5-dev \
libopenal-dev \
libssl-dev \
libvorbis-dev \
mercurial \
zlib1g-dev
hg clone -r stable-2.0 http://hg.icculus.org/icculus/physfs/
mkdir -p physfs/build
pushd physfs/build
cmake ..
make -j$(nproc)
sudo make install
popd
script: | script: |
cmake . -DCMAKE_BUILD_TYPE=Release cmake . -DCMAKE_BUILD_TYPE=Release
make make -j$(nproc)
notifications: notifications:
irc: irc:
channels: channels:

View File

@ -1,31 +1,49 @@
from ubuntu:latest FROM ubuntu@sha256:b88f8848e9a1a4e4558ba7cfc4acc5879e1d0e7ac06401409062ad2627e6fb58 AS builder
WORKDIR /app RUN apt-get update; \
apt-get install -y \
build-essential \
cmake \
git-core \
libboost-atomic1.65-dev \
libboost-chrono1.65-dev \
libboost-date-time1.65-dev \
libboost-filesystem1.65-dev \
libboost-system1.65-dev \
libboost-thread1.65-dev \
libglew-dev \
liblua5.1-0-dev \
libncurses5-dev \
libopenal-dev \
libssl-dev \
libvorbis-dev \
mercurial \
zlib1g-dev; \
apt-get clean && apt-get autoclean
RUN apt-get update; apt-get install -y \ WORKDIR /
build-essential \ RUN hg clone -r stable-2.0 http://hg.icculus.org/icculus/physfs/
cmake \ WORKDIR /physfs/build/
git-core \ RUN cmake ..
libboost-all-dev \ RUN make -j$(nproc)
libglew-dev \ RUN make install
liblua5.1-0-dev \
libopenal-dev \
libphysfs-dev \
libssl-dev \
libvorbis-dev \
zlib1g-dev
RUN apt-get install -y \ COPY ./src/ /otclient/src/.
libncurses5-dev \ COPY CMakeLists.txt /otclient/.
mercurial; \ WORKDIR /otclient/build/
hg clone -r stable-2.0 http://hg.icculus.org/icculus/physfs/; \ RUN cmake -DCMAKE_CXX_LINK_FLAGS=-no-pie -DCMAKE_BUILD_TYPE=Release ..
cd physfs; \ RUN make -j$(nproc)
mkdir build && cd build && cmake .. && make && make install; \
mv /usr/local/lib/libphysfs.a /usr/lib/x86_64-linux-gnu/.
ADD . /app FROM ubuntu@sha256:b88f8848e9a1a4e4558ba7cfc4acc5879e1d0e7ac06401409062ad2627e6fb58
RUN apt-get update; \
# Build application apt-get install -y \
RUN mkdir -p build && cd build && cmake .. && make -j$(grep -c ^process /proc/cpuinfo); libglew2.0 \
libopenal1; \
CMD cd build; ./otclient apt-get clean && apt-get autoclean
COPY --from=builder /otclient/build/otclient /otclient/bin/otclient
COPY ./data/ /otclient/data/.
COPY ./mods/ /otclient/mods/.
COPY ./modules/ /otclient/modules/.
COPY ./init.lua /otclient/.
WORKDIR /otclient
CMD ["./bin/otclient"]

View File

@ -38,13 +38,28 @@ In short, if you need to compile OTClient, follow these tutorials:
### Build and run with Docker ### Build and run with Docker
To build and run the client: To build the image:
```
./build.sh ```sh
./run.sh docker build -t edubart/otclient .
``` ```
The build step should be run just when something on implementation changes. To run the built image:
```sh
# Disable access control for the X server.
xhost +
# Run the container image with the required bindings to the host devices and volumes.
docker run -it --rm \
--env DISPLAY \
--volume /tmp/.X11-unix:/tmp/.X11-unix \
--device /dev/dri \
--device /dev/snd edubart/otclient /bin/bash
# Enable access control for the X server.
xhost -
```
### Need help? ### Need help?

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
docker build -t edubart/otclient .

19
run.sh
View File

@ -1,19 +0,0 @@
#!/usr/bin/env bash
SE_enforcing=`getenforce` || true
sudo setenforce Permissive || true
# Enable any host to connect on X Org
xhost +
docker run -ti --rm \
-e DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--device /dev/dri \
edubart/otclient
# Enable any host to connect on X Org
xhost -
sudo setenforce $SE_enforcing || true