pass in UID and GID so hounted volumes have correct owner (todo: make it dynameic)

This commit is contained in:
Gitea 2020-12-11 11:14:32 +00:00
parent e95651837f
commit fcc6b97d58
3 changed files with 15 additions and 4 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
UID=1002 #$(id -u)
GID=1002 #$(id -g)

View File

@ -1,6 +1,9 @@
FROM golang:1.15-alpine3.12 FROM golang:1.15-alpine3.12
ARG GOPROXY ARG GOPROXY
ARG UID
ARG GID
ENV GOPROXY ${GOPROXY:-direct} ENV GOPROXY ${GOPROXY:-direct}
ARG GITEA_VERSION ARG GITEA_VERSION
@ -15,6 +18,8 @@ WORKDIR /src
EXPOSE 22 3000 EXPOSE 22 3000
RUN echo DEBUG: "gg ${GID} uu ${UID}"
RUN apk --no-cache add \ RUN apk --no-cache add \
bash \ bash \
ca-certificates \ ca-certificates \
@ -29,13 +34,13 @@ RUN apk --no-cache add \
gnupg gnupg
RUN addgroup \ RUN addgroup \
-S -g 1000 \ -S -g ${GID} \
git && \ git && \
adduser \ adduser \
-S -H -D \ -S -H -D \
-h /home/git \ -h /home/git \
-s /bin/bash \ -s /bin/bash \
-u 1000 \ -u ${UID} \
-G git \ -G git \
git && \ git && \
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd

View File

@ -1,10 +1,14 @@
version: '3.1' version: '3.1'
services: services:
gitea-dev: gitea-dev:
build: dev build:
context: dev
args:
UID: "${UID}"
GID: "${GID}"
ports: ports:
- 3000:3000 - 3000:3000
user: 1000:1000 user: "${UID}:${GID}"
volumes: volumes:
- ./home:/home - ./home:/home
- ./src:/src - ./src:/src