Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to Dockerize #17

Closed
ridwankustanto opened this issue Dec 19, 2019 · 3 comments
Closed

Failed to Dockerize #17

ridwankustanto opened this issue Dec 19, 2019 · 3 comments
Assignees

Comments

@ridwankustanto
Copy link

Description

Version: v2.2.0
Commit: bc72e19

Description

Hi, thank you for making this framework! I found it on Medium post, and it looks promising and I would give it a try for my next project.

But recently, I try to install and gave log a bit for knowning what app and port that I was running on with goyave config, everything was fine, till I try to dockerize this app. It was running but the config file fell into default.json, I use FROM alpine:3.9 as my production build phase:

FROM golang:alpine as builder
.
.
.

FROM alpine:3.9

RUN apk add --no-cache tzdata
ENV TZ Asia/Jakarta

COPY --from=builder /go/pkg/mod/github.com/!system-!glitch/goyave/ /go/pkg/mod/github.com/!system-!glitch/goyave/
COPY --from=builder /app/config.json /app/
COPY --from=builder /app/resources /app/resources
COPY --from=builder /app/app /app/app

# Run the binary.
ENTRYPOINT ["/app/app"] 

docker-compose up and the container was running, but when I hit the default port for localhost:8080, the server not actually running.

Did I do wrong? What files that I need to copy in order to make the binary runs? as you can see I already copy config.json and resources as you mentioned on documents.

Thanks once again! 😁

@System-Glitch System-Glitch self-assigned this Dec 19, 2019
@System-Glitch
Copy link
Member

System-Glitch commented Dec 19, 2019

Hello, I think the only problem with your Dockerfile is that you forgot WORKDIR. The config file is looked for in the working directory.

I used the following Dockerfile and it worked: (with docker-goyave as project name)

FROM golang:alpine as builder

WORKDIR /app

COPY . .

RUN go build

FROM alpine:3.9

WORKDIR /app

COPY --from=builder /go/pkg/mod/github.com/!system-!glitch/goyave/ /go/pkg/mod/github.com/!system-!glitch/goyave/
COPY --from=builder /app/docker-goyave ./docker-goyave
COPY resources /app/resources
COPY config.json ./config.json

EXPOSE 8080

ENTRYPOINT [ "./docker-goyave" ]

I should add this dockerfile to the documentation too.

I will also try to bundle default files inside the binary to avoid having to copy /go/pkg/mod/github.com/!system-!glitch/goyave/.

@ridwankustanto
Copy link
Author

Hey, thank you for quick response. I did set WORKDIR but I cut in the example (my bad 😅). I forgot the expose, thanks for the full example! I will try once I get home and let you know.

@ridwankustanto
Copy link
Author

Just able to try this out, and thanks mate, it worked. Anyway, your idea about putting the default config bundle inside the binary would be great!

And now I'm gonna try to store something into the database. 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants