From e02c0830f5b7978dae17b9b315b06d337f7e913a Mon Sep 17 00:00:00 2001 From: Nikolay Nechaev Date: Sun, 10 Mar 2024 00:07:09 +0300 Subject: [PATCH] Lab 6 bonus task + crucial bug fixes in app_go --- ansible/playbooks/dev/app_go/main.yml | 18 ++++++++++++++++++ app_go/Dockerfile | 5 +++-- app_go/main.go | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 ansible/playbooks/dev/app_go/main.yml diff --git a/ansible/playbooks/dev/app_go/main.yml b/ansible/playbooks/dev/app_go/main.yml new file mode 100644 index 0000000000..5f31ee0630 --- /dev/null +++ b/ansible/playbooks/dev/app_go/main.yml @@ -0,0 +1,18 @@ +- name: Deploy go app + hosts: all + roles: + - name: "Deploy kolay0ne/app_go:lab6" + role: web_app + image_name: "kolay0ne/app_go" + image_tag: "lab6" + publish_ports: + - "5500:5000" + wipe: false + tags: [] # Run by default + + - name: "Wipe kolay0ne/app_go:lab6" + role: web_app + image_name: "kolay0ne/app_go" + image_tag: "lab6" + wipe: true + tags: [never, wipe] # Only run on wipe diff --git a/app_go/Dockerfile b/app_go/Dockerfile index 15dfe646fa..01c76e9961 100644 --- a/app_go/Dockerfile +++ b/app_go/Dockerfile @@ -9,8 +9,9 @@ COPY go.mod *.go /usr/src/app/ RUN ["env", "CGO_ENABLED=0", "go", "build", "-o", "catfact_webapp", "."] -# Like `FROM scratch` but with SSL -FROM damdo/sscratch +FROM scratch +# Enable https requests from within the container +COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt EXPOSE 5000 diff --git a/app_go/main.go b/app_go/main.go index ee57e27cac..10fc818861 100644 --- a/app_go/main.go +++ b/app_go/main.go @@ -10,7 +10,7 @@ func handler(w http.ResponseWriter, r *http.Request) { fact, err := catFact() if err == nil { w.WriteHeader(http.StatusOK) - _, _ = fmt.Fprintf(w, fact) + _, _ = fmt.Fprintf(w, "%s", fact) } else { w.WriteHeader(http.StatusInternalServerError) _, _ = fmt.Fprintf(w, "Failed to query a cat fact :(")