Skip to content

Commit 57a3104

Browse files
committed
Changed the docker file to use user account.
1 parent 4cda1ee commit 57a3104

5 files changed

Lines changed: 34 additions & 27 deletions

File tree

Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@ FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION} AS final
1818
WORKDIR /app
1919

2020
RUN apt-get update \
21-
&& apt-get install -y --no-install-recommends curl gosu \
21+
&& apt-get install -y --no-install-recommends curl \
2222
&& rm -rf /var/lib/apt/lists/*
2323

2424
COPY --from=build /app/publish ./
25-
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
2625

27-
RUN mkdir -p /data /config \
28-
&& chown -R app:app /app \
29-
&& chmod +x /usr/local/bin/docker-entrypoint.sh
26+
RUN mkdir -p /data /config
3027

3128
ENV ASPNETCORE_URLS=http://+:8080 \
3229
ASPNETCORE_HTTP_PORTS=8080 \
30+
HOME=/data \
3331
ConnectionStrings__DefaultConnection="DataSource=/data/m3undle.db;Cache=Shared" \
3432
M3Undle__Logging__LogDirectory=/data/logs \
3533
M3Undle__Snapshot__Directory=/data/snapshots \
@@ -41,5 +39,4 @@ EXPOSE 8080
4139
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
4240
CMD curl --fail --silent http://127.0.0.1:8080/health || exit 1
4341

44-
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
45-
CMD ["dotnet", "M3Undle.Web.dll"]
42+
ENTRYPOINT ["dotnet", "M3Undle.Web.dll"]

compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
dockerfile: Dockerfile
66
image: m3undle:local
77
container_name: m3undle
8+
user: "${PUID}:${PGID}"
89
ports:
910
- "8080:8080"
1011
environment:

docker-entrypoint.sh

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

docs/DOCKER.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ services:
2424
m3undle:
2525
image: ghcr.io/sydney-elvis/m3undle:alpha
2626
container_name: m3undle
27+
user: "${PUID}:${PGID}"
2728
ports:
2829
- "8080:8080"
2930
environment:
@@ -34,6 +35,21 @@ services:
3435
restart: unless-stopped
3536
```
3637
38+
Create a `.env` file next to `compose.yaml` with your user and group IDs:
39+
40+
```env
41+
PUID=1000
42+
PGID=1000
43+
```
44+
45+
Find your IDs on Linux with `id`:
46+
47+
```bash
48+
$ id
49+
uid=1000(jake) gid=1000(jake) groups=1000(jake),998(docker)
50+
# PUID=1000 PGID=1000
51+
```
52+
3753
Then open `http://<host>:8080`.
3854

3955
### docker run
@@ -43,6 +59,7 @@ mkdir -p m3undle/config m3undle/data && cd m3undle
4359
4460
docker run -d \
4561
--name m3undle \
62+
--user "$(id -u):$(id -g)" \
4663
-p 8080:8080 \
4764
-e TZ=America/New_York \
4865
-v ./config:/config \
@@ -64,17 +81,6 @@ Both are required for data to persist across container restarts.
6481

6582
**Why bind mounts?** Bind mounts put files in a known place on the host. You can edit `config.yaml` with any editor, inspect logs, or wipe the data directory without going through Docker commands.
6683

67-
### Linux: ownership
68-
69-
The container runs as a non-root user (UID `64198`). On Linux with bind mounts, pre-create the directories with the correct owner before starting the container:
70-
71-
```bash
72-
mkdir -p config data
73-
chown -R 64198:64198 config data
74-
```
75-
76-
Docker Desktop on Mac and Windows handles this automatically.
77-
7884
### Named volumes (alternative)
7985

8086
If you prefer Docker-managed storage, named volumes work too — replace the bind mounts:

docs/dev/container.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ This document covers local container build/run for development.
77
- Docker Desktop (or Docker Engine + Compose plugin)
88
- Repo root as current directory
99

10+
## Setup
11+
12+
The compose file uses `user: "${PUID}:${PGID}"` so the container runs as your own user account. Create a `.env` file in the repo root before the first run:
13+
14+
```bash
15+
echo "PUID=$(id -u)" >> .env
16+
echo "PGID=$(id -g)" >> .env
17+
```
18+
19+
The `.env` file is already in `.gitignore`.
20+
1021
## Build And Run
1122

1223
Start the service with the provided compose file:
@@ -85,5 +96,5 @@ docker inspect --format='{{json .State.Health}}' m3undle
8596

8697
- DB schema migrations run on app startup.
8798
- App health endpoint is `GET /health`.
88-
- The container runs as UID `64198` (the built-in `app` user from the .NET runtime image).
99+
- The container runs as whatever user is set by `PUID`/`PGID` in `.env`.
89100
- If Docker in WSL is unavailable, enable WSL integration in Docker Desktop.

0 commit comments

Comments
 (0)