Compose app skeletons

Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
Anca Iordache
2020-02-13 14:14:36 +01:00
parent 1936fc4fe2
commit 4a619921b9
14 changed files with 184 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
FROM golang:1.13 AS builder
WORKDIR /compose/hello-docker
COPY main.go main.go
RUN CGO_ENABLED=0 go build -o backend main.go
FROM scratch
COPY --from=builder /compose/hello-docker/backend /usr/local/bin/backend
CMD ["/usr/local/bin/backend"]

View File

@@ -0,0 +1,14 @@
version: "3.6"
services:
frontend:
image: nginx
ports:
- 8080:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- backend
backend:
build: .

View File

@@ -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))
}

View File

@@ -0,0 +1,6 @@
server {
listen 80;
location / {
proxy_pass http://backend:80;
}
}