Skip to content

Commit

Permalink
Modularized devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Apr 26, 2024
1 parent 27d2a25 commit 9f6ec29
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 13 deletions.
7 changes: 1 addition & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ FROM buildpack-deps:${VARIANT}-curl

USER root

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get upgrade -y \
&& apt-get -y install --no-install-recommends \
# Mono
mono-devel

ARG USERNAME=developer
ARG USER_UID=1000
ARG USER_GID=$USER_UID
Expand All @@ -19,6 +13,7 @@ RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
Expand Down
18 changes: 18 additions & 0 deletions .devcontainer/bannerlord/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": "bannerlord",
"version": "1.0.0",
"name": "Bannerlord",
"documentationURL": "",
"description": "Bannerlord",
"containerEnv": {
"BANNERLORD_GAME_DIR": "/bannerlord",
"BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL": "${localEnv:BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL}"
},
"mounts": [
{
"source":"${localEnv:BANNERLORD_GAME_DIR}",
"target":"/bannerlord",
"type":"bind"
}
]
}
29 changes: 22 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
"cacheFrom": "ghcr.io/butr/bannerlord.blse:latest"
},
"features": {
"./upgrade": {

},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": "false"
},
"./mono": {

},
"ghcr.io/devcontainers/features/dotnet:2": {

},
Expand All @@ -17,23 +23,30 @@
}
},
"overrideFeatureInstallOrder": [
"./upgrade",
"ghcr.io/devcontainers/features/git",
"./mono",
"ghcr.io/devcontainers/features/dotnet",
"ghcr.io/devcontainers/features/powershell"
],
"mounts": [
"source=${localEnv:BANNERLORD_GAME_DIR},target=/bannerlord,type=bind,consistency=default"
],
"containerEnv": {
"BANNERLORD_GAME_DIR": "/bannerlord",
"BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL": "${localEnv:BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL}"
"DOTNET_CLI_TELEMETRY_OPTOUT": "true",
"DOTNET_HTTPREPL_TELEMETRY_OPTOUT": "true",
"DOTNET_NOLOGO": "true",
"DOTNET_SKIP_FIRST_TIME_EXPERIENCE": "true",
"DOTNET_USE_POLLING_FILE_WATCHER": "true",
"NUGET_XMLDOC_MODE": "skip"
},
"postStartCommand": {
"dotnet restore": "dotnet restore src/Bannerlord.BLSE.sln"
},
"postAttachCommand": "dotnet restore src/Bannerlord.BLSE.sln",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.powershell",
"editorconfig.editorconfig",
"github.vscode-github-actions",
"ms-vscode.powershell",
"ms-azuretools.vscode-docker",
"ms-dotnettools.csdevkit"
],
Expand All @@ -46,7 +59,9 @@
},
"powershell.powerShellAdditionalExePaths": {
"pwsh": "/usr/local/bin/pwsh"
}
},
"telemetry.telemetryLevel": "off",
"dotnetAcquisitionExtension.enableTelemetry": false
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions .devcontainer/mono/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "mono",
"version": "1.0.0",
"name": "Mono",
"documentationURL": "",
"description": "Mono"
}
10 changes: 10 additions & 0 deletions .devcontainer/mono/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive

echo "(*) Installing 7z"
apt-get update
apt-get install -y --no-install-recommends mono-devel
apt-get clean -y
rm -rf /var/lib/apt/lists/*;

echo "Done!"
7 changes: 7 additions & 0 deletions .devcontainer/upgrade/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "upgrade",
"version": "1.0.0",
"name": "Upgrade",
"documentationURL": "",
"description": "Upgrade"
}
10 changes: 10 additions & 0 deletions .devcontainer/upgrade/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive

echo "(*) Upgrading"
apt-get update
apt-get upgrade -y
apt-get clean -y
rm -rf /var/lib/apt/lists/*;

echo "Done!"
33 changes: 33 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Dev Container Build and Push Image

on:
workflow_dispatch:
push:
branches:
- master
paths:
- '.devcontainer/*'
- '.github/workflows/devcontainer.yml'

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
-
name: Checkout
id: checkout
uses: actions/checkout@v4
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: BUTR
password: ${{ secrets.TOKEN_GPR }}
-
name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/butr/bannerlord.blse
cacheFrom: ghcr.io/butr/bannerlord.blse
push: always

0 comments on commit 9f6ec29

Please sign in to comment.