Adding simple Traefik example. (#44)
Adding simple Traefik example. Signed-off-by: lfache <61111030+lfache@users.noreply.github.com>pull/83/head
parent
8e678f132c
commit
3a0f551e33
@ -0,0 +1,11 @@ |
|||||||
|
FROM golang:1.13 AS build |
||||||
|
|
||||||
|
WORKDIR /compose/hello-docker |
||||||
|
COPY main.go main.go |
||||||
|
RUN CGO_ENABLED=0 go build -o backend main.go |
||||||
|
|
||||||
|
FROM scratch |
||||||
|
COPY --from=build /compose/hello-docker/backend /usr/local/bin/backend |
||||||
|
CMD ["/usr/local/bin/backend"] |
||||||
|
|
||||||
|
|
@ -0,0 +1,30 @@ |
|||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"log" |
||||||
|
"net/http" |
||||||
|
) |
||||||
|
|
||||||
|
func handler(w http.ResponseWriter, r *http.Request) { |
||||||
|
fmt.Println(r.URL.RawQuery) |
||||||
|
fmt.Fprintf(w, ` |
||||||
|
## . |
||||||
|
## ## ## == |
||||||
|
## ## ## ## ## === |
||||||
|
/"""""""""""""""""\___/ === |
||||||
|
{ / ===- |
||||||
|
\______ O __/ |
||||||
|
\ \ __/ |
||||||
|
\____\_______/ |
||||||
|
|
||||||
|
|
||||||
|
Hello from Docker! |
||||||
|
|
||||||
|
`) |
||||||
|
} |
||||||
|
|
||||||
|
func main() { |
||||||
|
http.HandleFunc("/", handler) |
||||||
|
log.Fatal(http.ListenAndServe(":80", nil)) |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
version: "3.7" |
||||||
|
services: |
||||||
|
frontend: |
||||||
|
image: traefik:2.2 |
||||||
|
command: --providers.docker --entrypoints.web.address=:80 --providers.docker.exposedbydefault=false |
||||||
|
ports: |
||||||
|
# The HTTP port |
||||||
|
- "80:80" |
||||||
|
volumes: |
||||||
|
# So that Traefik can listen to the Docker events |
||||||
|
- /var/run/docker.sock:/var/run/docker.sock |
||||||
|
depends_on: |
||||||
|
- backend |
||||||
|
backend: |
||||||
|
build: backend |
||||||
|
labels: |
||||||
|
- "traefik.enable=true" |
||||||
|
- "traefik.http.routers.go.rule=Path(`/`)" |
||||||
|
- "traefik.http.services.go.loadbalancer.server.port=80" |
Loading…
Reference in new issue