mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
Customise UID/GID for Docker (#63)
This commit is contained in:
parent
98c85de3d6
commit
da19e486f2
3 changed files with 37 additions and 8 deletions
15
Dockerfile
15
Dockerfile
|
@ -21,10 +21,11 @@ COPY . .
|
|||
RUN make
|
||||
|
||||
|
||||
FROM alpine:3.17
|
||||
FROM alpine:3.17 as run
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache \
|
||||
shadow \
|
||||
openssl \
|
||||
openssh \
|
||||
curl \
|
||||
|
@ -36,10 +37,14 @@ RUN apk update && \
|
|||
musl-dev \
|
||||
libstdc++
|
||||
|
||||
WORKDIR /opengist
|
||||
RUN addgroup -S opengist && \
|
||||
adduser -S -G opengist -H -s /bin/ash -g 'Opengist User' opengist
|
||||
|
||||
COPY --from=build /opengist/opengist .
|
||||
WORKDIR /app/opengist
|
||||
|
||||
COPY --from=build --chown=opengist:opengist /opengist/opengist .
|
||||
COPY --from=build --chown=opengist:opengist /opengist/docker ./docker
|
||||
|
||||
EXPOSE 6157 2222
|
||||
VOLUME /root/.opengist
|
||||
CMD ["./opengist"]
|
||||
VOLUME /opengist
|
||||
ENTRYPOINT ["./docker/entrypoint.sh"]
|
||||
|
|
17
README.md
17
README.md
|
@ -56,9 +56,9 @@ A self-hosted pastebin **powered by Git**. [Try it here](https://opengist.thomic
|
|||
A Docker [image](https://github.com/thomiceli/opengist/pkgs/container/opengist), available for each release, can be pulled
|
||||
|
||||
```shell
|
||||
docker pull ghcr.io/thomiceli/opengist:1.3 # most recent release
|
||||
docker pull ghcr.io/thomiceli/opengist:1.3 # most recent release, stable
|
||||
|
||||
docker pull ghcr.io/thomiceli/opengist:latest # latest development version
|
||||
docker pull ghcr.io/thomiceli/opengist:latest # latest development version, unstable
|
||||
```
|
||||
|
||||
It can be used in a `docker-compose.yml` file :
|
||||
|
@ -79,7 +79,18 @@ services:
|
|||
- "6157:6157" # HTTP port
|
||||
- "2222:2222" # SSH port, can be removed if you don't use SSH
|
||||
volumes:
|
||||
- "$HOME/.opengist:/root/.opengist"
|
||||
- "$HOME/.opengist:/opengist"
|
||||
```
|
||||
|
||||
You can define which user/group should run the container and own the files by setting the `UID` and `GID` environment variables :
|
||||
|
||||
```yml
|
||||
services:
|
||||
opengist:
|
||||
# ...
|
||||
environment:
|
||||
UID: 1001
|
||||
GID: 1001
|
||||
```
|
||||
|
||||
### From source
|
||||
|
|
13
docker/entrypoint.sh
Executable file
13
docker/entrypoint.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
export USER=opengist
|
||||
PID=${PID:-1000}
|
||||
GID=${GID:-1000}
|
||||
groupmod -o -g "$GID" $USER
|
||||
usermod -o -u "$PID" $USER
|
||||
|
||||
chown -R "$USER:$USER" /opengist
|
||||
|
||||
export OG_OPENGIST_HOME=/opengist
|
||||
|
||||
su -m $USER -c "/app/opengist/opengist"
|
Loading…
Reference in a new issue