Skip to content

Commit 3cd556b

Browse files
committed
Fix: 비밀번호 반영 못하던 오류 수정
1 parent ff850db commit 3cd556b

3 files changed

Lines changed: 73 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,15 @@ docker run --rm --privileged lscr.io/linuxserver/qemu-static --reset
327327

328328
Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64`.
329329

330+
## Example for podman
331+
332+
```shell
333+
podman build -t code-server-fedora . --build-arg VERSION="1.0.1" --build-arg BUILD_DATE="2025.09.12" --build-arg CODE_RELEASE="4.103.2"
334+
```
335+
330336
## Versions
331337

338+
* **1.0.1:** - Fedora42로 전환. rust 개발 환경을 기본으로 추가.
332339
* **10.08.25:** - Let server listen on both ipv4 and ipv6.
333340
* **03.06.25:** - Allow setting PWA name using env var `PWA_APPNAME`.
334341
* **13.10.24:** - Only chown config folder when change to ownership or new install is detected.

container-root/usr/local/bin/start-code-server

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# Load file-based secrets: support envs like FILE__PASSWORD=/path
5+
load_file_envs() {
6+
while IFS='=' read -r name value; do
7+
if [[ $name == FILE__* ]]; then
8+
key="${name#FILE__}"
9+
if [[ -f "$value" ]]; then
10+
export "${key}=$(<"$value")"
11+
fi
12+
fi
13+
done < <(env)
14+
}
15+
16+
load_file_envs
17+
418
# Ensure required directories and ownership exist for logging and data
519
mkdir -p /config/{extensions,data,workspace,.ssh}
620
mkdir -p /config/.local/share/code-server/coder-logs
721

8-
# If running as root, fix ownership and perms, then drop privileges
22+
# If running as root, align user IDs, sudo and permissions, then drop privileges
923
if [[ "${EUID}" -eq 0 ]]; then
10-
chown -R 911:911 /config || true
24+
# Map user/group ids if provided
25+
CURRENT_UID=$(id -u abc)
26+
CURRENT_GID=$(id -g abc)
27+
TARGET_UID=${PUID:-$CURRENT_UID}
28+
TARGET_GID=${PGID:-$CURRENT_GID}
29+
30+
if [[ "$CURRENT_GID" != "$TARGET_GID" ]]; then
31+
EXISTING_GROUP=$(getent group "$TARGET_GID" | cut -d: -f1 || true)
32+
if [[ -n "${EXISTING_GROUP}" ]]; then
33+
usermod -g "$EXISTING_GROUP" abc
34+
else
35+
groupmod -g "$TARGET_GID" abc
36+
fi
37+
fi
38+
39+
if [[ "$CURRENT_UID" != "$TARGET_UID" ]]; then
40+
usermod -u "$TARGET_UID" abc
41+
fi
42+
43+
# Configure sudo access if requested
44+
if [[ -n "${SUDO_PASSWORD_HASH:-}" || -n "${SUDO_PASSWORD:-}" ]]; then
45+
usermod -aG wheel abc || true
46+
if [[ -n "${SUDO_PASSWORD_HASH:-}" ]]; then
47+
echo "abc:${SUDO_PASSWORD_HASH}" | chpasswd -e
48+
elif [[ -n "${SUDO_PASSWORD:-}" ]]; then
49+
echo "abc:${SUDO_PASSWORD}" | chpasswd
50+
fi
51+
fi
52+
53+
# Fix ownership and perms for config
54+
chown -R $(id -u abc):$(id -g abc) /config || true
1155
chmod 700 /config/.ssh || true
56+
1257
# Drop to user abc to run code-server
1358
exec runuser -u abc -- "$0" "$@"
1459
fi

usage_example.container

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[Unit]
2+
Description=code-server
3+
4+
[Container]
5+
Image=localhost/code-server-fedora:latest
6+
Environment=TZ=Asia/Seoul
7+
Environment=PUID=%U
8+
Environment=PGID=%G
9+
Environment=DEFAULT_WORKSPACE=/config/workspace
10+
Environment=PWA_APPNAME=code-server
11+
Volume=%h/.local/share/code-server/config:/config:Z
12+
Volume=%h/.config/containers/secrets:/run/secrets:ro,Z
13+
# abc 유저의 비밀번호이자 code-server의 비밀번호
14+
Environment=FILE__PASSWORD=/run/secrets/code_server
15+
# abc 유저의 sudo 비밀번호
16+
Environment=FILE__SUDO_PASSWORD=/run/secrets/code_server
17+
18+
[Install]
19+
WantedBy=default.target

0 commit comments

Comments
 (0)