Closed traed closed 5 years ago
@krismeister - any thoughts? I'm not a frequent docker user and wouldn't be able to add much in terms of a suggestion for @traed.
I stumbled upon this too, as trying to deploy a ponzu project. My issue was that I was using the Dockerfile generated with the command 'ponzu new'. It worked when I tried to built the image from go/src/ponzu but not with the code generated by ponzu.
Here is my fix to this
# Base our image on an official, minimal image of our preferred golang
FROM golang:1.9
# Note: The default golang docker image, already has the GOPATH env variable set.
# GOPATH is located at /go
ENV PONZU_GITHUB github.com/ponzu-cms/ponzu
ENV PROJECT_ROOT $GOPATH/src/github.com/user/project
RUN go get $PONZU_GITHUB/...
# Consider updating package in the future. For instance ca-certificates etc.
# RUN apt-get update -qq && apt-get install -y build-essential
# Make the ponzu root directory
RUN mkdir -p $PROJECT_ROOT
# All commands will be run inside of ponzu root
WORKDIR $PROJECT_ROOT
# Copy the ponzu source into ponzu root.
COPY . .
RUN ponzu build
CMD ponzu run
So I'm working on trying to deploy the Docker container to Heroku. I figured if I could figure it out I'd open a PR to add the process to the deployment docs. However, I'm sitting stuck so hoping for some help. My Dockerfile
looks like this:
FROM golang:1.9
# GOPATH is located at /go
# ENV GO_SRC $GOPATH/src
ENV PONZU_GITHUB github.com/ponzu-cms/ponzu
ENV PROJECT_GITHUB https://github.com/itzsaga/bookshelf.git
ENV PROJECT_ROOT $GOPATH/src/github.com/itzsaga/bookshelf
RUN go get $PONZU_GITHUB/...
RUN mkdir -p $PROJECT_ROOT
WORKDIR $PROJECT_ROOT
RUN git clone $PROJECT_GITHUB .
RUN ponzu build
CMD ponzu run --port=$PORT
Yet I keep hitting an error. The Heroku logs are this:
2019-02-11T02:17:33.000000+00:00 app[api]: Build started by user *****@gmail.com
2019-02-11T02:18:56.291011+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-11T02:18:56.112624+00:00 app[api]: Deploy 0d17fdaa by user *****@gmail.com
2019-02-11T02:18:56.000000+00:00 app[api]: Build succeeded
2019-02-11T02:18:56.112624+00:00 app[api]: Release v13 created by user *****@gmail.com
2019-02-11T02:19:10.850384+00:00 heroku[web.1]: Starting process with command `/bin/sh -c ponzu\ run\ --port\=\24946`
2019-02-11T02:19:13.183819+00:00 app[web.1]: Server listening at localhost:24946 for HTTP requests...
2019-02-11T02:19:13.183836+00:00 app[web.1]:
2019-02-11T02:19:13.183838+00:00 app[web.1]: Visit '/admin' to get started.
2019-02-11T02:20:11.305284+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-11T02:20:11.310568+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-11T02:20:11.228835+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-02-11T02:20:11.228900+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-02-11T02:20:11.286392+00:00 heroku[web.1]: Process exited with status 137
I know this isn't technically an issue for Ponzu but I think getting a Heroku deployment hashed out could help a lot of people play around with and get Ponzu apps out into the wild.
What is stored in $PORT ?
@itzsaga - thank you for reporting (and @krismeister, for jumping in!)
I will hopefully have some time EOD today or tomorrow to take a look at this. Our Docker support has not been given enough attention (my fault!) and that should definitely change.
@krismeister $PORT
is a dynamically generated environment variable from Heroku. From https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime
The web process must listen for HTTP traffic on
$PORT
, which is set by Heroku.EXPOSE
inDockerfile
is not respected, but can be used for local testing. Only HTTP requests are supported.
I had the same problem and was struggling for few days, but finally I got it working! All I had to do is add --bind=0.0.0.0 to the "ponzu run"
Full Dockerfile looks like this:
# Latest GO 1
FROM golang:1
# Install Ponzu
ENV PONZU_GITHUB github.com/ponzu-cms/ponzu
RUN go get -u $PONZU_GITHUB/...
# Copy Project
ENV PROJECT_ROOT $GOPATH/src/project
RUN mkdir -p $PROJECT_ROOT
WORKDIR $PROJECT_ROOT
COPY . .
# Build & Run
RUN ponzu build
CMD ponzu run --port=$PORT --bind=0.0.0.0
And to deploy project to Heroku I made "deploy.sh" script:
heroku container:push web
heroku container:release web
heroku open
@goleh it works!!! Awesome! I'll queue this up for the docs so others don't get stuck and can deploy to Heroku easier.
Closing this issue. It appears to be answered/resolved. Please reopen if not the case.
Trying to build the Dockerfile produces errors.
Command used to get code:
ponzu new <name>
Command to build:docker build .
OS: MacOS 10.13.6 Docker version: 18.06.0-ce-mac70