From 2e7f52ea47de03e3222430f777756348401ec36a Mon Sep 17 00:00:00 2001 From: Beppe Vanrolleghem Date: Wed, 25 Mar 2020 11:20:14 +0100 Subject: [PATCH] go versie --- .DS_Store | Bin 8196 -> 8196 bytes src/.idea/.gitignore | 2 ++ src/.idea/misc.xml | 6 ++++++ src/.idea/modules.xml | 8 ++++++++ src/.idea/src.iml | 9 +++++++++ src/.idea/vcs.xml | 6 ++++++ src/app.py | 17 ----------------- src/dockerfile | 19 +++++++++---------- src/main.go | 15 +++++++++++++++ src/requirements.txt | 1 - 10 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 src/.idea/.gitignore create mode 100644 src/.idea/misc.xml create mode 100644 src/.idea/modules.xml create mode 100644 src/.idea/src.iml create mode 100644 src/.idea/vcs.xml delete mode 100644 src/app.py create mode 100644 src/main.go delete mode 100644 src/requirements.txt diff --git a/.DS_Store b/.DS_Store index 3147abca4e3b1dc0786c6b43b0b2f9289c82360e..71475cd876e9e0552113b7a55bfa8093ee1d7778 100644 GIT binary patch delta 496 zcmZp1XmQxkE>O?SkiwA4P{5GGkk3%bpa;Z>47m(Bo;mr+NjdpR3=9kcKx_@f8vnrn z$YNk%Wyoa6V@P8tVn{?&xe`q!Cqoc}D}y703xh9^)&rWIf~=#Sfq_vRO$#$aG0@;- zWMx1VAScW~aspIUQh9L!)S+LK3UV@wOAHKdFfuW-u(GjpaB^{Ta`SO>#|CHQmj{<5 zmXsDdB^JdC$OLDmq$VX6g=Y$-lw^dY=DFsimZj$T7x^TXq)t91;8`CH(h-nYk^xl3 zq3n>T0JNQffs=zXUO=L{+QigUN5RC*xK>A@+T7d#$Tl{st>xt8kW_aIiYsmEn>BmM z(q+pJ9R}-SU}S{Q41!P^MjZh%p#I2AE`$1madT3^<{H6MjMg_1(z*FAE>LfBG(CEM geZA-*M`YO)G}+0G!ls)S$s{pPEa2J9F7cNg0Gtqrxc~qF delta 417 zcmZp1XmQxkF5t|}P|Q%okepOrT#%HLpTxkxa4M-FC$qT3z~DL~6Eh1d8#@OF7Y7$F zS8Q-betB?7Vo7PSQ({pxh!>Dpl97}+dAguyAO{C02WPy1WOcQnfw{Skf}y2Jt&T#q zxw(Okg1MnZZ7nBM8XF_geRdr2m-7KI@K)}cdp&9t0G>n?P*0p}6FHLhM_umcJLHHgn}Q}gIYq>@o*U@B5{5*EbcR$0U4~4CJccx&cN25c4TF>O za|FPEI8-9rdgkYJg%kW>TXCvJxB{eF7r*j?3?yeTZrGeHGn08@0ncW3iNEXs Dhp1-+ diff --git a/src/.idea/.gitignore b/src/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/src/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/src/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/src/.idea/modules.xml b/src/.idea/modules.xml new file mode 100644 index 0000000..f669a0e --- /dev/null +++ b/src/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/.idea/src.iml b/src/.idea/src.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/src/.idea/src.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/.idea/vcs.xml b/src/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/src/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/app.py b/src/app.py deleted file mode 100644 index 17c58a2..0000000 --- a/src/app.py +++ /dev/null @@ -1,17 +0,0 @@ -from flask import Flask -from flask import jsonify -app = Flask(__name__) - - -@app.route('/') -def doRequest(): - data = { - "serverName": "backend-server", - "version": "experimental", - "success": "true" - } - return jsonify(data) - - -if __name__ == '__main__': - app.run(debug=True, host="0.0.0.0", port=80) diff --git a/src/dockerfile b/src/dockerfile index e9ef308..5bb9295 100644 --- a/src/dockerfile +++ b/src/dockerfile @@ -1,10 +1,9 @@ -from python:3.7-alpine - -copy . /app -workdir /app - -run pip install -r requirements.txt -expose 80 -entrypoint [ "python" ] - -cmd [ "app.py" ] +FROM golang:alpine as builder +RUN mkdir /build +COPY main.go /build/main.go +WORKDIR /build +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main . +FROM scratch +COPY --from=builder /build/main /main +EXPOSE 80 +CMD ["./main"] \ No newline at end of file diff --git a/src/main.go b/src/main.go new file mode 100644 index 0000000..e10e4c6 --- /dev/null +++ b/src/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "net/http" +) + +func main() { + http.HandleFunc("/", HelloServer) + http.ListenAndServe(":80", nil) +} + +func HelloServer(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "{\"serverName\":\"backend-server\",\"success:false\",\"version\": \"experimental\"}") +} \ No newline at end of file diff --git a/src/requirements.txt b/src/requirements.txt deleted file mode 100644 index 2077213..0000000 --- a/src/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Flask \ No newline at end of file