Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "PLT",
"privileged": false,
"remoteUser": "plt",
"service": "plt",
"dockerComposeFile": "../docker-compose.yml",
"workspaceFolder": "/app",
"customizations": {
"jetbrains": {
"settings": {
"Docker:app:DockerSettings.dockerComposePath": "/usr/local/bin/docker-compose",
"Docker:app:DockerSettings.dockerPath": "/usr/bin/docker"
}
},
"vscode": {
"extensions": [
"ms-vscode.cmake-tools"
]
}
}
}
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
set -x
sudo apt-get update
sudo apt-get install -yy libsfml-dev libboost-test-dev libmicrohttpd-dev libxml2-dev xvfb lcov gcovr
sudo apt-get install -yy libsfml-dev libboost1.74-all-dev libmicrohttpd-dev libxml2-dev xvfb lcov gcovr

- name: switch to gcc-12 on linux
run: |
Expand All @@ -43,7 +43,7 @@ jobs:
set -x
mkdir build
cd build
cmake -DBOOST_ROOT=$BOOST_ROOT_1_69_0 -DBoost_ARCHITECTURE=-x64 ..
cmake -DBOOST_ROOT=$BOOST_ROOT_1_74_0 -DBoost_ARCHITECTURE=-x64 ..

# Compile project
- name: Compile project
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
*~
build
cmake-build-debug
build-docker
bin
nbproject
src/**/*.h
.idea
*.autosave
tmp
.env
47 changes: 39 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
FROM debian:stable-slim
FROM debian:stable-slim AS plt-base

ARG USERNAME
ARG USER_UID
ARG USER_GID
ARG DISPLAY


RUN groupadd --gid $USER_GID $USERNAME && \
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

RUN if [ -n "$DISPLAY" ]; then \
export DISPLAY=$DISPLAY; \
fi


# Install dependencies


RUN apt-get update && apt-get install -y \
build-essential \
cmake \
lcov \
gcovr
gcovr \
git

RUN apt-get update && apt-get install -y \
libsfml-dev \
libxml2-dev \
libboost-all-dev

RUN apt-get update && apt-get install -y \
dia

# Set the working directory
dia libcanberra-gtk3-module \
python3-gi gir1.2-gtk-3.0

# Set up user and working directory
RUN chsh -s /bin/bash $USERNAME
USER $USERNAME
WORKDIR /app
COPY --exclude=build --exclude=cmake-build-debug --chown=$USERNAME:$USERNAME . /app

COPY . /app
# Set environment variables for GUI support
RUN export GDK_BACKEND=$(if [ ! $WAYLAND_DISPLAY ]; then echo x11; else echo wayland; fi)
RUN export QT_QPA_PLATFORM=$(if [ ! $WAYLAND_DISPLAY ]; then echo xcb; else echo wayland; fi)

# Build the project
RUN mkdir docker-build && cd docker-build && cmake .. && make client
ENV LC_ALL="C.UTF-8"
ENV LANG="C.UTF-8"

RUN mkdir docker-build && cd docker-build && cmake .. && make client && cd ..

RUN chmod u+x ./entrypoint.sh

SHELL ["/bin/bash", "--login", "-c"]

# Run the application
CMD ["./bin/client"]
ENTRYPOINT ["./entrypoint.sh"]
CMD ["tail", "-f", "/dev/null"]
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
plt:
container_name: plt
working_dir: /app
build:
context: .
args:
USERNAME: ${username:-plt}
USER_UID: ${USER_UID:-1000} # $(id -u)
USER_GID: ${USER_GID:-1000} # $(id -g)
DISPLAY: ${DISPLAY}
dockerfile: Dockerfile
# user: $(id -u):$(id -g)
user: $USER_UID:$USER_GID
volumes:
- ./:/app
- /tmp/($WAYLAND_DISPLAY-):/tmp/($WAYLAND_DISPLAY-):rw
- /tmp/.X11-unix:/tmp/.X11-unix:rw
# - /dev/dri:/dev/dri:cached
tty: true
environment:
WAYLAND_DISPLAY: ${WAYLAND_DISPLAY:-}
env_file:
- .env
stdin_open: true
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

export GDK_BACKEND=$(if [ ! $WAYLAND_DISPLAY ]; then echo x11; else echo wayland; fi)
export QT_QPA_PLATFORM=$(if [ ! $WAYLAND_DISPLAY ]; then echo xcb; else echo wayland; fi)

exec "$@"
13 changes: 13 additions & 0 deletions setup_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -e

echo USERNAME=plt > ./.env
echo USER_UID=$(id -u) >> ./.env
echo USER_GID=$(id -g) >> ./.env

echo "Checking for display server..."
if [ "$XDG_SESSION_TYPE" != "wayland" ]; then
xhost +SI:localuser:$(id -un)
echo DISPLAY=$DISPLAY >> ./.env
fi