This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christopher Crone <[email protected]>
- Loading branch information
1 parent
6267dc4
commit 1fcfa27
Showing
7 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM golang:alpine AS build | ||
ARG MESSAGE | ||
WORKDIR /go/src | ||
COPY main.go . | ||
RUN CGO_ENABLED=0 go build -o /server -ldflags="-X main.Message=${MESSAGE} -s -w" main.go | ||
|
||
FROM scratch AS run | ||
ENTRYPOINT ["/server"] | ||
COPY --from=build /server /server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
var ( | ||
// Message is the text to serve | ||
Message string | ||
) | ||
|
||
func main() { | ||
if Message == "" { | ||
Message = "<h1>Hello from Docker App build demo!</h1>" | ||
} | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Printf("Serve request from: %s\n", r.RemoteAddr) | ||
fmt.Fprintf(w, Message) | ||
}) | ||
log.Fatal(http.ListenAndServe(":5000", nil)) | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/service-build/build-demo.dockerapp/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: "3.7" | ||
|
||
services: | ||
front: | ||
image: front | ||
build: | ||
context: front/ | ||
dockerfile: front.Dockerfile | ||
ports: | ||
- "${front.port}:80" | ||
|
||
back: | ||
image: back | ||
build: | ||
context: back/ | ||
dockerfile: back.Dockerfile | ||
args: | ||
- MESSAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Version of the application | ||
version: 0.1.0 | ||
# Name of the application | ||
name: build-demo | ||
# A short description of the application | ||
description: | ||
# List of application maintainers with name and email for each | ||
maintainers: | ||
- name: chris | ||
email: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
front: | ||
port: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM nginx:alpine | ||
COPY nginx-conf /etc/nginx/conf.d/default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
proxy_pass http://back:5000/; | ||
proxy_set_header Host "localhost"; | ||
} | ||
} |