# -- --
FROM docker:dind AS worker_dependencies
# -- --
# -- --
FROM img.liz.coffee/emprespresso/ci_base:release AS worker
ENV PIPELINE_PATH=/app/worker/dist/scripts
RUN chmod +x /app/worker/dist/scripts/*
RUN mkdir -p /var/lib/laminar/cfg
RUN cp -r /app/worker/jobs /var/lib/laminar/cfg
# see: https://github.com/nodejs/docker-node/blame/89b29ef06b421598ec007605a2604ede0348b298/22/bullseye-slim/Dockerfile#L3-L4
RUN chown -R node:node /var/lib/laminar
# laminar runs as `node`, which reaches the host's docker socket only through
# a group whose GID matches the socket's group ON THE HOST. Group names don't
# carry across the container boundary; only the number does. If this GID is
# wrong the worker gets "permission denied" on the socket, and the tempting
# fix - chmod 777 on the host socket - hands root on the host to every process
# and container there, not just CI.
#
# Set this to the output of `getent group docker | cut -d: -f3` on the host
# running the worker (liz.coffee: 988). Override with --build-arg DOCKER_GID=.
# (Coolify drops --group-add from custom docker options, so it can't be
# supplied at runtime there.)
ARG DOCKER_GID="988"
RUN groupadd -g ${DOCKER_GID} docker
RUN usermod -a -d /var/lib/laminar -G docker node
COPY --from=worker_dependencies /usr/local/bin/docker /usr/local/bin/
USER node
WORKDIR /var/lib/laminar
EXPOSE 8080
CMD [ "/usr/sbin/laminard" ]
# -- --