Skip to content

Commit 3b99669

Browse files
Set up devcontainer for Crossfire Server
- Added .devcontainer configuration with Dockerfile, docker-compose.yml, and devcontainer.json to configure the development environment. - Created Dockerfile to install dependencies including curl, git, git-lfs, pre-commit, and others for devcontainer setup. - Configured vscode service in devcontainer to use the 'crossfire-server' image. - Added postCreateCommand.sh for environment setup and git configuration. - Removed outdated GitHub Actions workflows (rollout.yaml, test.yaml). - Updated Dockerfile to improve image build efficiency and fix permissions for crossfire directories. - Removed unused nginx_vhost setting from Dockerfile.
1 parent e128593 commit 3b99669

File tree

10 files changed

+158
-72
lines changed

10 files changed

+158
-72
lines changed

.devcontainer/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG DEBIAN_VERSION=bookworm
2+
ARG HADOLINT=v2.12.0
3+
4+
FROM mcr.microsoft.com/vscode/devcontainers/base:$DEBIAN_VERSION
5+
6+
LABEL maintainer="Bob Tanner <[email protected]>"
7+
8+
# hadolint ignore=DL3008
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends \
11+
curl \
12+
git \
13+
git-lfs \
14+
less \
15+
vim-tiny \
16+
openssh-client \
17+
pre-commit \
18+
&& apt-get autoremove \
19+
&& apt-get clean \
20+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
21+
22+
ARG USERNAME=vscode
23+
ARG USER_UID=3000
24+
ARG USER_GID=3000
25+
26+
RUN echo "vscode ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vscode \
27+
&& if ! getent group vscode; then groupadd --gid 3000 vscode; fi \
28+
&& if ! id -u vscode > /dev/null 2>&1; then useradd --uid 3000 --gid 3000 -m vscode; fi
29+
30+
EXPOSE 8000

.devcontainer/devcontainer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "crossfire-server",
3+
"dockerComposeFile": [
4+
"docker-compose.yml"
5+
],
6+
"service": "vscode",
7+
"workspaceFolder": "/workspace",
8+
"shutdownAction": "stopCompose",
9+
"features": {
10+
"ghcr.io/dhoeric/features/hadolint:1": {}
11+
},
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"charliermarsh.ruff",
16+
"exiasr.hadolint",
17+
"kevinrose.vsc-python-indent",
18+
"mosapride.zenkaku",
19+
"ms-azuretools.vscode-docker",
20+
"ms-python.python",
21+
"ms-python.vscode-pylance",
22+
"njpwerner.autodocstring",
23+
"redhat.vscode-yaml",
24+
"shardulm94.trailing-spaces",
25+
"tamasfe.even-better-toml",
26+
"yzhang.markdown-all-in-one",
27+
"humao.rest-client",
28+
"ms-python.debugpy",
29+
"ms-playwright.playwright",
30+
"GitHub.copilot"
31+
]
32+
}
33+
},
34+
"containerEnv": {
35+
"DISPLAY": "dummy",
36+
"PYTHONUNBUFFERED": "True",
37+
},
38+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh && pre-commit install",
39+
"remoteUser": "vscode",
40+
"forwardPorts": [
41+
8000
42+
]
43+
}

.devcontainer/docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
services:
3+
vscode:
4+
container_name: crossfire-server-vscode
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
args:
9+
DEBIAN_VERSION: bookworm
10+
volumes:
11+
- ..:/workspace:cached
12+
environment:
13+
TZ: ${TZ:-America/Chicago}
14+
command: sleep infinity
15+
networks:
16+
- crossfire
17+
18+
networks:
19+
crossfire:
20+
name: crossfire
21+
driver: bridge
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.sql.gz
2+
*.sql.zip

.devcontainer/postCreateCommand.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
timezone_setup() {
6+
local TZ=${TZ}
7+
8+
if [ -z "$TZ" ]; then
9+
echo "==> Timezone not set"
10+
return
11+
fi
12+
13+
echo "==> Setting timezone to: $TZ"
14+
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
15+
sudo dpkg-reconfigure -f noninteractive tzdata
16+
}
17+
18+
echo "==> Working directory: $(pwd)"
19+
20+
# Load environment variables from .env file
21+
#
22+
echo "==> Load environment variables from .env file"
23+
if [ -f ".env" ]; then
24+
set -o allexport
25+
source ./.env
26+
set +o allexport
27+
fi
28+
29+
# Timezone setup
30+
#
31+
timezone_setup
32+
33+
echo "==> Customize git user configuration"
34+
git config --global core.eol lf
35+
git config --global core.autocrlf false
36+
git config --global http.sslVerify false
37+
git config --global core.editor "code --wait"
38+
git config --global --add safe.directory /workspace
39+
40+
echo "==> Setting git user.name: '${GIT_USER_EMAIL}'"
41+
git config --global user.email "${GIT_USER_EMAIL}"
42+
43+
echo "==> Setting git user.email: '${GIT_USER_NAME}'"
44+
git config --global user.name "${GIT_USER_NAME}"

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
venv
21
*.py[cod]
32
__pycache__
3+
venv

.github/workflows/rollout.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

Dockerfile

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,31 @@ FROM ubuntu:jammy
22

33
LABEL maintainer="[email protected]"
44
LABEL version="0.1"
5-
LABEL description="Docker Image for Crossfire"
5+
LABEL description="Docker Image for the Crossfire Server"
66

77
ARG DEBIAN_FRONTEND=noninteractive
88

9-
RUN apt --yes update && apt --yes dist-upgrade
10-
RUN apt --yes update && \
11-
apt install -y crossfire-server && \
12-
rm -rf /var/lib/apt/lists/* && \
13-
apt clean
14-
15-
ENV nginx_vhost /etc/nginx/sites-available/default
9+
RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes \
10+
&& apt-get update -qq \
11+
&& apt-get dist-upgrade -qq \
12+
&& apt-get install -qq --no-install-recommends \
13+
crossfire-server \
14+
&& apt-get autoremove \
15+
&& apt-get clean \
16+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1617

1718
VOLUME ["/var/games/crossfire/", "/var/log/crossfire"]
1819

1920
EXPOSE 13327
2021

21-
RUN install -d /app
2222
COPY entrypoint.sh /app
23-
RUN chmod +x /app/entrypoint.sh
24-
RUN touch /var/games/crossfire/highscore
25-
RUN install -d /var/games/crossfire/datafiles
26-
RUN install -d /var/games/crossfire/players
27-
RUN install -d /var/games/crossfire/unique-items
28-
RUN chown -R games:games /var/games/crossfire
23+
24+
RUN install -d /app \
25+
&& chmod +x /app/entrypoint.sh \
26+
&& touch /var/games/crossfire/highscore \
27+
&& install -d /var/games/crossfire/datafiles \
28+
&& install -d /var/games/crossfire/players \
29+
&& install -d /var/games/crossfire/unique-items \
30+
&& chown -R games:games /var/games/crossfire \
2931

3032
CMD [ "/app/entrypoint.sh" ]

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
version: '3.9'
3-
42
services:
53
crossfire-server:
64
build:

0 commit comments

Comments
 (0)