Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Add service image build example #723

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/service-build/back/Dockerfile
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
23 changes: 23 additions & 0 deletions examples/service-build/back/main.go
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))
}
17 changes: 17 additions & 0 deletions examples/service-build/build-demo.dockerapp/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.7"

services:
front:
build:
context: front/
dockerfile: Dockerfile
ports:
- "${front.port}:80"

back:
build:
context: back/
dockerfile: Dockerfile
args:
- MESSAGE

10 changes: 10 additions & 0 deletions examples/service-build/build-demo.dockerapp/metadata.yml
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware, you'll have to maintain this app! 🧌

email:
2 changes: 2 additions & 0 deletions examples/service-build/build-demo.dockerapp/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
front:
port: 8080
2 changes: 2 additions & 0 deletions examples/service-build/front/Dockerfile
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
9 changes: 9 additions & 0 deletions examples/service-build/front/nginx-conf
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";
}
}