Docker: Use variables to set UID & GID in development environments
This commit is contained in:
parent
a564cff3af
commit
3aee5e8d78
6 changed files with 38 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM photoprism/development:20201215
|
FROM photoprism/development:20210115
|
||||||
|
|
||||||
# Set up project directory
|
# Set up project directory
|
||||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -9,6 +9,7 @@ export GO111MODULE=on
|
||||||
GOIMPORTS=goimports
|
GOIMPORTS=goimports
|
||||||
BINARY_NAME=photoprism
|
BINARY_NAME=photoprism
|
||||||
DOCKER_TAG=`date -u +%Y%m%d`
|
DOCKER_TAG=`date -u +%Y%m%d`
|
||||||
|
UID=`(id -u)`
|
||||||
|
|
||||||
HASRICHGO := $(shell which richgo)
|
HASRICHGO := $(shell which richgo)
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ start:
|
||||||
stop:
|
stop:
|
||||||
go run cmd/photoprism/photoprism.go stop
|
go run cmd/photoprism/photoprism.go stop
|
||||||
terminal:
|
terminal:
|
||||||
docker-compose exec photoprism bash
|
docker-compose exec -u $(UID) photoprism bash
|
||||||
root-terminal:
|
root-terminal:
|
||||||
docker-compose exec -u root photoprism bash
|
docker-compose exec -u root photoprism bash
|
||||||
migrate:
|
migrate:
|
||||||
|
|
|
@ -20,8 +20,6 @@ services:
|
||||||
security_opt:
|
security_opt:
|
||||||
- seccomp:unconfined
|
- seccomp:unconfined
|
||||||
- apparmor:unconfined
|
- apparmor:unconfined
|
||||||
# Uncomment and edit the following line to set a specific user / group id:
|
|
||||||
# user: "1000:1000"
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- photoprism-db
|
- photoprism-db
|
||||||
ports:
|
ports:
|
||||||
|
@ -32,6 +30,8 @@ services:
|
||||||
- "go-mod:/go/pkg/mod"
|
- "go-mod:/go/pkg/mod"
|
||||||
shm_size: "2gb"
|
shm_size: "2gb"
|
||||||
environment:
|
environment:
|
||||||
|
UID: ${UID:-1000}
|
||||||
|
GID: ${GID:-1000}
|
||||||
TF_CPP_MIN_LOG_LEVEL: 0 # Show TensorFlow log messages for development
|
TF_CPP_MIN_LOG_LEVEL: 0 # Show TensorFlow log messages for development
|
||||||
PHOTOPRISM_SITE_URL: "http://localhost:2342/"
|
PHOTOPRISM_SITE_URL: "http://localhost:2342/"
|
||||||
PHOTOPRISM_SITE_TITLE: "PhotoPrism"
|
PHOTOPRISM_SITE_TITLE: "PhotoPrism"
|
||||||
|
|
|
@ -154,5 +154,9 @@ WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||||
EXPOSE 2342 2343 9515
|
EXPOSE 2342 2343 9515
|
||||||
VOLUME /var/lib/photoprism
|
VOLUME /var/lib/photoprism
|
||||||
|
|
||||||
# Keep container running (services can be started manually using a terminal)
|
# Configure entrypoint
|
||||||
CMD tail -f /dev/null
|
COPY --chown=root:root /docker/development/entrypoint.sh /entrypoint.sh
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
|
# Run server
|
||||||
|
CMD ["tail", "-f", "/dev/null"]
|
26
docker/development/entrypoint.sh
Executable file
26
docker/development/entrypoint.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ ${UMASK} ]]; then
|
||||||
|
umask "${UMASK}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
find /go -type d -print0 | xargs -0 chmod 777
|
||||||
|
chmod -R a+rw /var/lib/photoprism /go
|
||||||
|
|
||||||
|
if [[ ${UID} ]] && [[ ${GID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
|
||||||
|
groupadd -f -g "${GID}" "${GID}"
|
||||||
|
usermod -o -u "${UID}" -g "${GID}" photoprism
|
||||||
|
chown -R photoprism:photoprism /photoprism /var/lib/photoprism /go
|
||||||
|
gosu "${UID}:${GID}" "$@" &
|
||||||
|
elif [[ ${UID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
|
||||||
|
usermod -o -u "${UID}" photoprism
|
||||||
|
chown -R photoprism /photoprism /var/lib/photoprism /go
|
||||||
|
gosu "${UID}" "$@" &
|
||||||
|
else
|
||||||
|
"$@" &
|
||||||
|
fi
|
||||||
|
|
||||||
|
PID=$!
|
||||||
|
|
||||||
|
trap "kill $PID" INT TERM
|
||||||
|
wait
|
|
@ -1,4 +1,4 @@
|
||||||
FROM photoprism/development:20201215 as build
|
FROM photoprism/development:20210115 as build
|
||||||
|
|
||||||
# Set up project directory
|
# Set up project directory
|
||||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||||
|
|
Loading…
Reference in a new issue