diff --git a/Dockerfile b/Dockerfile index 969e4de..f70f79d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ WORKDIR /build RUN apk add -u git RUN \ if [ -z "$CI" ] ; then \ - echo "runs outside of CI" && version=$(git log -1 --format=%h)-$(date +%Y%m%dT%H:%M:%S); \ + echo "runs outside of CI" && version=$(git rev-parse --abbrev-ref HEAD)-$(git log -1 --format=%h)-$(date +%Y%m%dT%H:%M:%S); \ else version=${GIT_BRANCH}-${GITHUB_SHA:0:7}-$(date +%Y%m%dT%H:%M:%S); fi && \ echo "version=$version" && \ cd app && go build -o /build/reproxy -ldflags "-X main.revision=${version} -s -w" @@ -23,17 +23,20 @@ FROM alpine:3.13 ENV \ TERM=xterm-color \ - TIME_ZONE=America/Chicago + TIME_ZONE=UTC RUN \ - apk add --no-cache --update tzdata curl ca-certificates && \ + apk add --no-cache --update tzdata curl ca-certificates dumb-init && \ cp /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime && \ echo "${TIME_ZONE}" > /etc/timezone && date && \ + ln -s /usr/bin/dumb-init /sbin/dinit && \ rm -rf /var/cache/apk/* +COPY init.sh /init.sh COPY --from=backend /build/reproxy /srv/reproxy RUN chmod +x /srv/reproxy LABEL reproxy.enabled="false" WORKDIR /srv -ENTRYPOINT ["/srv/reproxy"] +ENTRYPOINT ["/init.sh"] +CMD ["/srv/reproxy"] \ No newline at end of file diff --git a/examples/docker/docker-compose.yml b/examples/docker/docker-compose.yml index 29ec5f1..145d9dc 100644 --- a/examples/docker/docker-compose.yml +++ b/examples/docker/docker-compose.yml @@ -13,6 +13,7 @@ services: - DOCKER_ENABLED=true - ASSETS_LOCATION=/web - DEBUG=true + - TIME_ZONE=America/Chicago svc1: image: hashicorp/http-echo diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..14bec7d --- /dev/null +++ b/init.sh @@ -0,0 +1,15 @@ +#!/sbin/dinit /bin/sh + +uid=$(id -u) + +if [[ ${uid} -eq 0 ]]; then + echo "init container" + + # set container's time zone + cp /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime + echo "${TIME_ZONE}" >/etc/timezone + echo "set timezone ${TIME_ZONE} ($(date))" +fi + +echo "execute \"$@\"" +exec $@