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
|
||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||
|
|
3
Makefile
3
Makefile
|
@ -9,6 +9,7 @@ export GO111MODULE=on
|
|||
GOIMPORTS=goimports
|
||||
BINARY_NAME=photoprism
|
||||
DOCKER_TAG=`date -u +%Y%m%d`
|
||||
UID=`(id -u)`
|
||||
|
||||
HASRICHGO := $(shell which richgo)
|
||||
|
||||
|
@ -51,7 +52,7 @@ start:
|
|||
stop:
|
||||
go run cmd/photoprism/photoprism.go stop
|
||||
terminal:
|
||||
docker-compose exec photoprism bash
|
||||
docker-compose exec -u $(UID) photoprism bash
|
||||
root-terminal:
|
||||
docker-compose exec -u root photoprism bash
|
||||
migrate:
|
||||
|
|
|
@ -20,8 +20,6 @@ services:
|
|||
security_opt:
|
||||
- seccomp:unconfined
|
||||
- apparmor:unconfined
|
||||
# Uncomment and edit the following line to set a specific user / group id:
|
||||
# user: "1000:1000"
|
||||
depends_on:
|
||||
- photoprism-db
|
||||
ports:
|
||||
|
@ -32,6 +30,8 @@ services:
|
|||
- "go-mod:/go/pkg/mod"
|
||||
shm_size: "2gb"
|
||||
environment:
|
||||
UID: ${UID:-1000}
|
||||
GID: ${GID:-1000}
|
||||
TF_CPP_MIN_LOG_LEVEL: 0 # Show TensorFlow log messages for development
|
||||
PHOTOPRISM_SITE_URL: "http://localhost:2342/"
|
||||
PHOTOPRISM_SITE_TITLE: "PhotoPrism"
|
||||
|
|
|
@ -154,5 +154,9 @@ WORKDIR "/go/src/github.com/photoprism/photoprism"
|
|||
EXPOSE 2342 2343 9515
|
||||
VOLUME /var/lib/photoprism
|
||||
|
||||
# Keep container running (services can be started manually using a terminal)
|
||||
CMD tail -f /dev/null
|
||||
# Configure entrypoint
|
||||
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
|
||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||
|
|
Loading…
Reference in a new issue