Search code examples
dockerherokujbosskeycloak

Deploying keycloak docker image to heroku


I am trying to deploy my custom keycloak docker image which is extended from jboss/keycloak to heroku container stack.

Its deployed successfully but it errors out saying permission denied on start itself.

I am new to heroku container. Can some one help me please?

Here is my heroku.yml file

    addons:
        - plan: heroku-postgresql:hobby-dev
          as: DATABASE
build:
    docker:
        web: Dockerfile

here is my docker file

FROM jboss/keycloak:latest
ENV DB_PORT 5432
ENV DB_DATABASE mydatabase
ENV DB_USER myuser
ENV DB_PASSWORD mypassword
ENV DB_VENDOR postgres
ENV DB_ADDR postgres
ENV KEYCLOAK_USER mykeycloak
ENV KEYCLOAK_PASSWORD mykeycloakpassword
ENV PORT 8080
COPY standalone.xml /opt/jboss/keycloak/standalone/standalone.xml
COPY standalone.xml /opt/jboss/keycloak/standalone/configuration/standalone.xml
COPY meraklis /opt/jboss/keycloak/themes/mytheme
COPY docker-entrypoint.sh /opt/jboss/tools
ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ]
CMD ["-b", "0.0.0.0"]

and here are the errors in heroku logs

2020-03-18T05:07:02.975073+00:00 heroku[web.1]: Starting process with command `-b 0.0.0.0`
2020-03-18T05:07:05.796708+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-18T05:07:05.773550+00:00 heroku[web.1]: Process exited with status 126
2020-03-18T05:07:05.733774+00:00 app[web.1]: Error: Permission denied

Solution

  • I noticed that it actually is not heroku issue but docker one. Heroku does not allow to run any script or command as root while running the container. It adds a dummy non-root user to container and the container run under that user context under workdir you specified in dockerfile. You need to give execute permission to the shell script in order to make it run properly. That was the issue in my case