Skip to content

Commit

Permalink
Lab 6 bonus task + crucial bug fixes in app_go
Browse files Browse the repository at this point in the history
  • Loading branch information
kolayne committed Mar 9, 2024
1 parent 54ffb17 commit e02c083
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
18 changes: 18 additions & 0 deletions ansible/playbooks/dev/app_go/main.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions app_go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app_go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 :(")
Expand Down

0 comments on commit e02c083

Please sign in to comment.