Skip to content

Commit

Permalink
all: use dynamic host address and revise docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
changkun committed Nov 11, 2021
1 parent 6f632c2 commit 8d03e73
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/code2img/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func main() {
log.Printf("[%s]: write screenshot error %v", imgfile, err)
return
}
c.String(http.StatusOK, "https://golang.design/api/v1/code2img/data/images/"+id+".png")
c.String(http.StatusOK, "https://"+c.Request.Host+"/api/v1/code2img/data/images/"+id+".png")
})

s := &http.Server{Addr: ":8080", Handler: router}
s := &http.Server{Addr: ":80", Handler: router}
go func() {
if err := s.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatalf("listen: %s\n", err)
Expand Down
Binary file added code2img
Binary file not shown.
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ RUN apt update && apt install dumb-init
ENTRYPOINT ["dumb-init", "--"]
WORKDIR /app
COPY . .
EXPOSE 80
CMD ["/app/code2img"]
10 changes: 8 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ services:
image: code2img
cap_add:
- SYS_PTRACE # for debugging
ports:
- "5656:8080"
deploy:
replicas: 1
networks:
- traefik_proxy
networks:
traefik_proxy:
external: true

0 comments on commit 8d03e73

Please sign in to comment.