Skip to content

Commit 6e830a2

Browse files
committed
feat: add Docker support with Dockerfile, docker-compose.yml, and .dockerignore; update README.md with Docker build instructions and dev container setup
1 parent 75dac0c commit 6e830a2

File tree

6 files changed

+281
-15
lines changed

6 files changed

+281
-15
lines changed

.devcontainer/devcontainer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Chocolate Doom (Emscripten)",
3+
"dockerComposeFile": "../docker-compose.yml",
4+
"service": "build",
5+
"workspaceFolder": "/workspace",
6+
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"ms-vscode.cpptools",
11+
"ms-vscode.cmake-tools",
12+
"ms-python.python"
13+
],
14+
"settings": {
15+
"terminal.integrated.defaultProfile.linux": "bash",
16+
"files.exclude": {
17+
"**/.git": true,
18+
"**/.DS_Store": true
19+
}
20+
}
21+
}
22+
},
23+
24+
"postCreateCommand": "source /opt/emsdk/emsdk_env.sh && echo 'Emscripten environment ready!'",
25+
26+
"remoteUser": "root",
27+
28+
"features": {
29+
"ghcr.io/devcontainers/features/git:1": {}
30+
}
31+
}
32+
33+
34+

.dockerignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Build artifacts
6+
*.o
7+
*.lo
8+
*.la
9+
*.a
10+
*.so
11+
*.wasm
12+
src/chocolate-*.js
13+
src/chocolate-*.html
14+
15+
# Autotools
16+
aclocal.m4
17+
autom4te.cache
18+
autotools
19+
Makefile
20+
Makefile.in
21+
config.h
22+
config.hin
23+
config.log
24+
config.status
25+
configure
26+
lib
27+
obj
28+
stamp-h*
29+
rpm.spec
30+
31+
# IDE
32+
.vscode
33+
.vs
34+
*.swp
35+
*.swo
36+
*~
37+
38+
# OS
39+
.DS_Store
40+
Thumbs.db
41+
42+
# Documentation
43+
*.md
44+
!README.md
45+
46+
# CI/CD
47+
.github
48+

.github/workflows/deploy.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,26 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- name: Setup Emscripten
25-
uses: mymindstorm/setup-emsdk@v12
26-
with:
27-
version: 'latest'
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
2826

29-
- name: Install dependencies
30-
run: |
31-
sudo apt-get update
32-
sudo apt-get install -y autoconf automake libtool pkg-config
27+
- name: Build Docker image
28+
uses: docker/build-push-action@v5
29+
with:
30+
context: .
31+
push: false
32+
load: true
33+
tags: ascii-doom:latest
34+
cache-from: type=gha
35+
cache-to: type=gha,mode=max
3336

34-
- name: Build
37+
- name: Build project
3538
run: |
36-
autoreconf -fiv
37-
emconfigure ./configure --enable-emscripten
38-
emmake make -j4 -k
39+
docker run --rm \
40+
-v ${{ github.workspace }}:/workspace \
41+
-w /workspace \
42+
ascii-doom:latest \
43+
/usr/local/bin/build.sh
3944
4045
- name: Setup Pages
4146
uses: actions/configure-pages@v4

Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM ubuntu:22.04
2+
3+
# 환경 변수 설정 (tzdata 설치 시 대화형 프롬프트 방지)
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
ENV EMSDK=/opt/emsdk
6+
7+
# 필수 도구 및 의존성 설치
8+
RUN apt-get update && apt-get install -y \
9+
git \
10+
build-essential \
11+
autoconf \
12+
automake \
13+
libtool \
14+
pkg-config \
15+
python3 \
16+
python3-pip \
17+
cmake \
18+
ninja-build \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Emscripten SDK 설치
22+
WORKDIR /opt
23+
RUN git clone https://github.com/emscripten-core/emsdk.git && \
24+
cd emsdk && \
25+
./emsdk install latest && \
26+
./emsdk activate latest
27+
28+
# Emscripten 환경 변수 설정
29+
ENV PATH="${EMSDK}/upstream/emscripten:${PATH}"
30+
ENV EMSDK_PYTHON=/usr/bin/python3
31+
32+
# 작업 디렉토리 설정
33+
WORKDIR /workspace
34+
35+
# 빌드 스크립트 생성
36+
RUN echo '#!/bin/bash\n\
37+
set -e\n\
38+
source /opt/emsdk/emsdk_env.sh\n\
39+
echo "Generating configure script..."\n\
40+
autoreconf -fiv\n\
41+
echo "Configuring with Emscripten..."\n\
42+
emconfigure ./configure --enable-emscripten\n\
43+
echo "Building..."\n\
44+
emmake make -j$(nproc) -k\n\
45+
echo "Build complete! Output files are in src/ directory."' > /usr/local/bin/build.sh && \
46+
chmod +x /usr/local/bin/build.sh
47+
48+
# 기본 명령어
49+
CMD ["/bin/bash"]
50+

README.md

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,123 @@ Chocolate Doom compiled to WebAssembly for running in web browsers.
44

55
## Prerequisites
66

7-
- **Emscripten SDK**: `brew install emscripten` (macOS) or install from [emscripten.org](https://emscripten.org)
8-
- **Autotools**: `brew install autoconf automake libtool` (macOS)
9-
- **Python 3**
7+
### Docker (모든 플랫폼 - 권장)
8+
9+
**Docker만 설치하면 모든 플랫폼(macOS, Windows, Linux)에서 동일하게 빌드할 수 있습니다.**
10+
11+
- **Docker Desktop**: [docker.com](https://www.docker.com/products/docker-desktop)에서 다운로드 및 설치
12+
- **Docker Compose**: Docker Desktop에 포함되어 있음
13+
14+
### macOS
15+
16+
- **Emscripten SDK**: `brew install emscripten` or install from [emscripten.org](https://emscripten.org)
17+
- **Autotools**: `brew install autoconf automake libtool`
18+
- **pkg-config**: `brew install pkgconf`
19+
- **Python 3**: Usually pre-installed, or `brew install python3`
20+
21+
### Windows
22+
23+
Windows에서는 다음 두 가지 방법 중 하나를 선택할 수 있습니다:
24+
25+
#### 방법 1: MSYS2 사용 (권장)
26+
27+
1. **MSYS2 설치**: [msys2.org](https://www.msys2.org/)에서 다운로드 및 설치
28+
2. **MSYS2 터미널 실행** 후 다음 명령어 실행:
29+
```bash
30+
# 패키지 업데이트
31+
pacman -Syu
32+
33+
# 필수 도구 설치
34+
pacman -S base-devel autoconf automake libtool pkgconf python
35+
36+
# Emscripten SDK 설치
37+
git clone https://github.com/emscripten-core/emsdk.git
38+
cd emsdk
39+
./emsdk install latest
40+
./emsdk activate latest
41+
source ./emsdk_env.sh
42+
```
43+
44+
3. **MSYS2 터미널에서 프로젝트 빌드** (이 터미널에서 모든 빌드 명령어 실행)
45+
46+
#### 방법 2: WSL (Windows Subsystem for Linux)
47+
48+
1. **WSL 설치**: PowerShell에서 `wsl --install` 실행
49+
2. **WSL 터미널 실행** 후:
50+
```bash
51+
# Ubuntu/Debian 기반
52+
sudo apt-get update
53+
sudo apt-get install -y autoconf automake libtool pkg-config python3 python3-pip
54+
55+
# Emscripten SDK 설치
56+
git clone https://github.com/emscripten-core/emsdk.git
57+
cd emsdk
58+
./emsdk install latest
59+
./emsdk activate latest
60+
source ./emsdk_env.sh
61+
```
62+
63+
3. **WSL 터미널에서 프로젝트 빌드**
64+
65+
### Linux
66+
67+
- **Autotools**: `sudo apt-get install autoconf automake libtool pkg-config` (Ubuntu/Debian) or `sudo yum install autoconf automake libtool pkgconfig` (RHEL/CentOS)
68+
- **Emscripten SDK**: [emscripten.org](https://emscripten.org)에서 설치
69+
- **Python 3**: Usually pre-installed
1070

1171
## Build
1272

73+
### Dev Container 사용 (가장 권장 - VS Code/Cursor)
74+
75+
**Cursor나 VS Code에서 컨테이너 내부에서 직접 개발할 수 있습니다:**
76+
77+
1. **Cursor/VS Code에서 프로젝트 열기**
78+
2. **명령 팔레트** (`Cmd+Shift+P` / `Ctrl+Shift+P`) 열기
79+
3. **"Dev Containers: Reopen in Container"** 선택
80+
4. 컨테이너가 빌드되고 자동으로 연결됩니다
81+
82+
컨테이너 내부에서:
83+
- 터미널이 자동으로 컨테이너 환경에서 실행됩니다
84+
- Emscripten이 자동으로 설정됩니다
85+
- 바로 빌드할 수 있습니다:
86+
87+
```bash
88+
# 빌드 스크립트 사용
89+
/usr/local/bin/build.sh
90+
91+
# 또는 수동으로
92+
source /opt/emsdk/emsdk_env.sh
93+
autoreconf -fiv
94+
emconfigure ./configure --enable-emscripten
95+
emmake make -j4 -k
96+
```
97+
98+
### Docker Compose 사용
99+
100+
모든 플랫폼에서 동일하게 작동합니다:
101+
102+
```bash
103+
# Docker 이미지 빌드 (최초 1회만, 시간이 걸릴 수 있음)
104+
docker-compose build
105+
106+
# 컨테이너 내에서 빌드 실행
107+
docker-compose run --rm build /usr/local/bin/build.sh
108+
109+
# 또는 컨테이너에 접속해서 수동으로 빌드
110+
docker-compose run --rm build bash
111+
# 컨테이너 내에서:
112+
# source /opt/emsdk/emsdk_env.sh
113+
# autoreconf -fiv
114+
# emconfigure ./configure --enable-emscripten
115+
# emmake make -j4 -k
116+
```
117+
118+
빌드된 파일은 호스트의 `src/` 디렉토리에 생성됩니다.
119+
120+
### 로컬 빌드
121+
122+
Docker 없이 로컬에서 빌드하려면:
123+
13124
```bash
14125
# Generate configure script
15126
autoreconf -fiv

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
build:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
volumes:
7+
- .:/workspace
8+
- build-cache:/root/.emscripten_cache
9+
working_dir: /workspace
10+
environment:
11+
- EMSDK=/opt/emsdk
12+
command: sleep infinity
13+
stdin_open: true
14+
tty: true
15+
16+
volumes:
17+
build-cache:
18+

0 commit comments

Comments
 (0)