mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 16:55:40 +00:00
Fix build when current user's UID is not 1000
By default, yq user created in Docker image will have UID 1000. However, the mounted volume will keep their existing UID:GID inside the container, and will cause permissoin error when they don't belong to the same UID:GID that yq belong to. This commit fixes yq's permission before building.
This commit is contained in:
parent
1bdd0a46be
commit
94e7a14662
@ -228,30 +228,27 @@ RUN apt-get -qq -y --no-install-recommends install \
|
|||||||
libdistro-info-perl \
|
libdistro-info-perl \
|
||||||
pandoc \
|
pandoc \
|
||||||
rsync \
|
rsync \
|
||||||
sensible-utils && \
|
sensible-utils \
|
||||||
|
sudo && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /tmp/* /var/tmp/*
|
rm -rf /tmp/* /var/tmp/*
|
||||||
|
|
||||||
COPY --from=golang /usr/local/go /usr/local/go
|
COPY --from=golang /usr/local/go /usr/local/go
|
||||||
|
|
||||||
# build debian package as yq user
|
# build debian package as yq user
|
||||||
RUN useradd -ms /bin/bash yq && \
|
RUN adduser --gecos yq --disabled-password yq && \
|
||||||
mkdir /home/yq/src && chown -R yq: /home/yq/src && \
|
mkdir /home/yq/src && \
|
||||||
mkdir /home/yq/output && chown -R yq: /home/yq/output
|
mkdir /home/yq/output
|
||||||
|
|
||||||
ADD ./build/dput.cf /etc/dput.cf
|
ADD ./build/dput.cf /etc/dput.cf
|
||||||
ADD ./build/build.sh /usr/bin/build.sh
|
ADD ./build/build.sh /usr/bin/build.sh
|
||||||
RUN chmod +x /usr/bin/build.sh && chown -R yq: /usr/bin/build.sh
|
RUN chmod +x /usr/bin/build.sh
|
||||||
|
|
||||||
USER yq
|
|
||||||
|
|
||||||
WORKDIR /home/yq/src
|
WORKDIR /home/yq/src
|
||||||
VOLUME ["/home/yq/src"]
|
VOLUME ["/home/yq/src"]
|
||||||
|
|
||||||
# dir where output packages are finally left
|
# dir where output packages are finally left
|
||||||
VOLUME ["/home/yq/output"]
|
VOLUME ["/home/yq/output"]
|
||||||
|
|
||||||
CMD ["/usr/bin/build.sh"]
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
DOCKER_BUILDKIT=1 docker build --pull -f "${blddir}"/Dockerfile -t "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" .
|
DOCKER_BUILDKIT=1 docker build --pull -f "${blddir}"/Dockerfile -t "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" .
|
||||||
@ -260,5 +257,4 @@ docker run --rm -i \
|
|||||||
-v "${srcdir}":/home/yq/src:delegated \
|
-v "${srcdir}":/home/yq/src:delegated \
|
||||||
-v "${OUTPUT}":/home/yq/output \
|
-v "${OUTPUT}":/home/yq/output \
|
||||||
-v "${HOME}"/.gnupg:/home/yq/.gnupg:delegated \
|
-v "${HOME}"/.gnupg:/home/yq/.gnupg:delegated \
|
||||||
-u "$(id -u)" \
|
"${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" bash -c "sed -i -E \"s/^(yq):(x?):([0-9]+):([0-9]+):(.*):(.*):(.*)$/\1:\2:$(id -u):$(id -g):\5:\6:\7/\" /etc/passwd && chown -R yq:yq /home/yq && sudo -u yq /usr/bin/build.sh"
|
||||||
"${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user