Skip to content

Commit c8b5794

Browse files
authored
Merge pull request #1 from appsinacup/add-dev-container
Add dev container
2 parents ab12536 + 68fa5b8 commit c8b5794

4 files changed

Lines changed: 150 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "tiny_lobby",
3+
"image": "ghcr.io/appsinacup/service_multiplayer/tiny-lobby-dev:latest",
4+
"remoteUser": "vscode",
5+
"containerEnv": {
6+
"DEBIAN_FRONTEND": "noninteractive"
7+
},
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-vscode.cpptools",
12+
"ms-vscode.cmake-tools",
13+
"twxs.cmake"
14+
],
15+
"settings": {
16+
"cmake.generator": "Ninja",
17+
"cmake.configureOnOpen": false
18+
}
19+
}
20+
},
21+
"workspaceFolder": "/workspaces/tiny_lobby",
22+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/tiny_lobby,type=bind",
23+
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}"
24+
}

.github/workflows/dev-image.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: build-dev-image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'Dockerfile.dev'
8+
- '.github/workflows/dev-image.yml'
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Login to GHCR
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Extract metadata (tags, labels)
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}/tiny-lobby-dev
36+
tags: |
37+
type=raw,value=latest
38+
type=sha
39+
40+
- name: Build and push
41+
uses: docker/build-push-action@v6
42+
with:
43+
context: .
44+
file: ./Dockerfile.dev
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max

.vscode/tasks.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://json.schemastore.org/tasks.json",
23
"version": "2.0.0",
34
"tasks": [
45
{
@@ -10,6 +11,30 @@
1011
"isDefault": true
1112
},
1213
"problemMatcher": []
14+
},
15+
{
16+
"label": "Build (Linux Debug)",
17+
"type": "shell",
18+
"command": "bash -lc ./bash/build_debug-x64.sh",
19+
"group": "build",
20+
"problemMatcher": ["$gcc"],
21+
"options": {
22+
"env": {
23+
"VCPKG_ROOT": "/opt/vcpkg"
24+
}
25+
}
26+
},
27+
{
28+
"label": "Build (Linux Release)",
29+
"type": "shell",
30+
"command": "bash -lc ./bash/build_release-x64.sh",
31+
"group": "build",
32+
"problemMatcher": ["$gcc"],
33+
"options": {
34+
"env": {
35+
"VCPKG_ROOT": "/opt/vcpkg"
36+
}
37+
}
1338
}
1439
]
1540
}

Dockerfile.dev

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Reusable dev image for tiny_lobby development
2+
# Contains compilers, cmake, ninja, ccache and vcpkg with all required ports preinstalled
3+
4+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
5+
6+
ENV DEBIAN_FRONTEND=noninteractive \
7+
CCACHE_DIR=/home/vscode/.cache/ccache \
8+
CCACHE_MAXSIZE=2G \
9+
CMAKE_C_COMPILER_LAUNCHER=ccache \
10+
CMAKE_CXX_COMPILER_LAUNCHER=ccache \
11+
VCPKG_ROOT=/opt/vcpkg \
12+
VCPKG_DEFAULT_TRIPLET=x64-linux \
13+
VCPKG_FORCE_SYSTEM_BINARIES=1
14+
15+
RUN apt-get update && apt-get install -y --no-install-recommends \
16+
build-essential \
17+
ninja-build \
18+
cmake \
19+
curl ca-certificates git pkg-config zip unzip \
20+
autoconf automake libtool ccache \
21+
zlib1g-dev libssl-dev libpq-dev && \
22+
rm -rf /var/lib/apt/lists/*
23+
24+
# Install vcpkg and preinstall required ports
25+
RUN git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT" && \
26+
"$VCPKG_ROOT"/bootstrap-vcpkg.sh -disableMetrics && \
27+
set -eux; \
28+
"$VCPKG_ROOT"/vcpkg install \
29+
boost-uuid \
30+
inih \
31+
libpqxx \
32+
openssl \
33+
boost-container \
34+
luau \
35+
zlib \
36+
boost-beast \
37+
efsw \
38+
"libdeflate[compression,decompression,zlib]" \
39+
"uwebsockets[libdeflate]" && \
40+
"$VCPKG_ROOT"/vcpkg integrate install || true
41+
42+
# Add a non-root user compatible with devcontainers
43+
ARG USERNAME=vscode
44+
ARG USER_UID=1000
45+
ARG USER_GID=$USER_UID
46+
RUN groupadd --gid $USER_GID $USERNAME \
47+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
48+
&& usermod -aG sudo $USERNAME \
49+
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
50+
51+
USER $USERNAME
52+
WORKDIR /workspaces/tiny_lobby

0 commit comments

Comments
 (0)