mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 04:52: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
|
RUN make
|
||||||
|
|
||||||
|
|
||||||
FROM alpine:3.17
|
FROM alpine:3.17 as run
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
|
shadow \
|
||||||
openssl \
|
openssl \
|
||||||
openssh \
|
openssh \
|
||||||
curl \
|
curl \
|
||||||
|
@ -36,10 +37,14 @@ RUN apk update && \
|
||||||
musl-dev \
|
musl-dev \
|
||||||
libstdc++
|
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
|
EXPOSE 6157 2222
|
||||||
VOLUME /root/.opengist
|
VOLUME /opengist
|
||||||
CMD ["./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
|
A Docker [image](https://github.com/thomiceli/opengist/pkgs/container/opengist), available for each release, can be pulled
|
||||||
|
|
||||||
```shell
|
```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 :
|
It can be used in a `docker-compose.yml` file :
|
||||||
|
@ -79,7 +79,18 @@ services:
|
||||||
- "6157:6157" # HTTP port
|
- "6157:6157" # HTTP port
|
||||||
- "2222:2222" # SSH port, can be removed if you don't use SSH
|
- "2222:2222" # SSH port, can be removed if you don't use SSH
|
||||||
volumes:
|
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
|
### 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