From 85f773d39d1a6811d45fe18349c9dc3bad761522 Mon Sep 17 00:00:00 2001 From: DutchEllie Date: Sun, 13 Mar 2022 19:34:20 +0100 Subject: [PATCH] Separate staging and production image --- .drone.yml | 15 ++++++++++++++- Dockerfile | 11 ++++++++++- components/guestbookpanel.go | 4 ++++ components/homepage.go | 5 +++++ web/static/style.css | 2 ++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 42942dd..2085f93 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,8 +16,9 @@ steps: password: from_secret: docker_password repo: dutchellie/proper-website-2 + target: staging tags: - - latest + - dev - ${DRONE_COMMIT_SHA:0:8} - name: deploy-staging image: pelotech/drone-helm3 @@ -54,6 +55,18 @@ trigger: - production steps: +- name: docker + image: plugins/docker + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: dutchellie/proper-website-2 + target: production + tags: + - latest + - ${DRONE_COMMIT_SHA:0:8} - name: deploy-production image: pelotech/drone-helm3 settings: diff --git a/Dockerfile b/Dockerfile index 858b15b..ffc356d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,20 @@ RUN go mod tidy RUN GOARCH=wasm GOOS=js go build -o web/app.wasm RUN go build -o app -FROM alpine:latest +FROM alpine:latest AS staging RUN apk --no-cache add ca-certificates WORKDIR /root/ COPY --from=builder /project/web ./web/ COPY --from=builder /project/app ./ EXPOSE 8000 +ENV TESTING = true CMD ["./app"] +FROM alpine:latest AS production +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY --from=builder /project/web ./web/ +COPY --from=builder /project/app ./ +EXPOSE 8000 +ENV TESTING = false +CMD ["./app"] \ No newline at end of file diff --git a/components/guestbookpanel.go b/components/guestbookpanel.go index 2c911ab..136f5c3 100644 --- a/components/guestbookpanel.go +++ b/components/guestbookpanel.go @@ -4,6 +4,7 @@ import ( "encoding/json" "io" "net/http" + "os" "time" "dutchellie.nl/DutchEllie/proper-website-2/entity" @@ -47,6 +48,9 @@ func (g *guestbookPanel) Render() app.UI { func (g *guestbookPanel) LoadComments() { // TODO: maybe you can put this in a localbrowser storage? url := apiurl + "api/comment" + if os.Getenv("TESTING") == "true" { + url = apiurl + "api/testingcomment" + } res, err := http.Get(url) if err != nil { app.Log(err) diff --git a/components/homepage.go b/components/homepage.go index 6ea538a..2fc03b7 100644 --- a/components/homepage.go +++ b/components/homepage.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net/http" + "os" "dutchellie.nl/DutchEllie/proper-website-2/entity" "github.com/maxence-charriere/go-app/v9/pkg/app" @@ -48,6 +49,10 @@ func (p *Homepage) Render() app.UI { return } url := apiurl + "api/comment" + if os.Getenv("TESTING") == "true" { + url = apiurl + "api/testingcomment" + } + req, err := http.Post(url, "application/json", bytes.NewBuffer(jsondata)) if err != nil { fmt.Printf("err: %v\n", err) diff --git a/web/static/style.css b/web/static/style.css index ce60cbc..f964ad3 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -88,6 +88,7 @@ body { div .name { text-align: left; + overflow-wrap: break-word; } div .date { @@ -99,6 +100,7 @@ div .date { .comment-message { color:white; + overflow-wrap: break-word; } .gb-modal {