-
-
Save wwerner/05a8e627e8f3ba18300db745511d3bcb to your computer and use it in GitHub Desktop.
| FROM openjdk:8-jdk-alpine | |
| VOLUME /tmp | |
| # see https://devcenter.heroku.com/articles/exec#enabling-docker-support | |
| RUN apk add --no-cache curl bash openssh python | |
| ADD src/main/docker/heroku-exec.sh /app/.profile.d/heroku-exec.sh | |
| RUN chmod a+x /app/.profile.d/heroku-exec.sh | |
| ADD src/main/docker/sh-wrapper.sh /bin/sh-wrapper.sh | |
| RUN chmod a+x /bin/sh-wrapper.sh | |
| RUN rm /bin/sh && ln -s /bin/sh-wrapper.sh /bin/sh |
| #!/usr/bin/env bash | |
| # see https://devcenter.heroku.com/articles/exec#enabling-docker-support | |
| [ -z "$SSH_CLIENT" ] && source <(curl --fail --retry 3 -sSL "$HEROKU_EXEC_URL") |
| #! /bin/bash | |
| /bin/bash "$@" |
sh-wrapper.sh could be replaced by setting set +o posix in heroku-exec.sh.
Thank you for this!
i found i had to add a python symlink to my dockerfile, to get this working with alpine in October 2020:
ln -s /usr/bin/python3 /usr/bin/python
here is a complete alpine dockerfile (for a basic nginx app), that works with heroku-exec:
FROM alpine:latest
# install required packages
RUN apk add --no-cache --update python3 bash curl openssh nginx
# simplfy nginx config to enable ENV variable substitution
RUN echo 'server { listen PORT_NUMBER; }' > /etc/nginx/conf.d/default.conf \
&& mkdir /run/nginx
# add config required for HEROKU_EXEC
# ENV HEROKU_EXEC_DEBUG=1
RUN rm /bin/sh \
&& ln -s /bin/bash /bin/sh \
&& mkdir -p /app/.profile.d/ \
&& printf '#!/usr/bin/env bash\n\nset +o posix\n\n[ -z "$SSH_CLIENT" ] && source <(curl --fail --retry 7 -sSL "$HEROKU_EXEC_URL")\n' > /app/.profile.d/heroku-exec.sh \
&& chmod +x /app/.profile.d/heroku-exec.sh \
&& ln -s /usr/bin/python3 /usr/bin/python
# configure NGINX to listen on dynamic $PORT env variable supplied by Heroku.
CMD sed -i 's/PORT_NUMBER/'"$PORT"'/g' /etc/nginx/conf.d/default.conf; nginx -g 'daemon off;'
I still can't seem to get this working. I've tried their longer, non-Ubuntu script as well, I have heroku-exec.sh in both possible locations, Python symlinked, set +o posix. I may have to try sh-wrapper.sh yet.
Thanks everyone! @MrFishFinger's solution for alpine worked for me.
I just got this working on alpine in a heroku docker container.
Thanks to @MrFishFinger et al.
The final piece of the puzzle was I had to explicitly call the script in our entrypoint.sh
It was located under /code/profile.d/ and that worked fine.
Sources: