Compose app skeletons
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
11
samples/nginx-gohttp_1/Dockerfile
Normal file
11
samples/nginx-gohttp_1/Dockerfile
Normal 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"]
|
||||
|
||||
|
14
samples/nginx-gohttp_1/docker-compose.yml
Normal file
14
samples/nginx-gohttp_1/docker-compose.yml
Normal 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: .
|
||||
|
30
samples/nginx-gohttp_1/main.go
Normal file
30
samples/nginx-gohttp_1/main.go
Normal 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))
|
||||
}
|
6
samples/nginx-gohttp_1/nginx.conf
Normal file
6
samples/nginx-gohttp_1/nginx.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
server {
|
||||
listen 80;
|
||||
location / {
|
||||
proxy_pass http://backend:80;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user