Prepare for deployment
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
# Build stage
|
||||
FROM golang:1.22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy and download dependencies
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the source code
|
||||
COPY . .
|
||||
|
||||
# Install required packages for cgo
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
|
||||
# Build with cgo enabled
|
||||
ENV CGO_ENABLED=1
|
||||
|
||||
# Build the Go application
|
||||
RUN go build -o app .
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
# Install SQLite CLI for runtime
|
||||
RUN apk add --no-cache sqlite
|
||||
|
||||
# Copy the binary from the builder stage
|
||||
COPY --from=builder /app/app .
|
||||
COPY --from=builder /app/static/index.html.tmpl ./static/index.html.tmpl
|
||||
COPY --from=builder /app/static/result.html.tmpl ./static/result.html.tmpl
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the application
|
||||
CMD ["./app"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module wa5p.eu/datefinder
|
||||
|
||||
go 1.22.0
|
||||
go 1.22
|
||||
|
||||
require github.com/mattn/go-sqlite3 v1.14.24
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
console.log(`Submitting dates for ${submitName.value}`)
|
||||
console.log(JSON.stringify(choices))
|
||||
|
||||
const url = "http://localhost:8080/api/submit";
|
||||
const url = "/api/submit";
|
||||
|
||||
fetch(url, {
|
||||
method: "POST", // Specify the HTTP method
|
||||
@@ -136,7 +136,7 @@
|
||||
submitBtn.remove()
|
||||
submitNameLabel.remove()
|
||||
|
||||
const textNode = document.createTextNode("Choices submitted. Thx.");
|
||||
const textNode = document.createTextNode("This is some text added to the body.");
|
||||
document.body.appendChild(textNode);
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
tooltip.style.color = "white";
|
||||
tooltip.style.borderRadius = "4px";
|
||||
tooltip.style.fontSize = "12px";
|
||||
tooltip.style.visibility = "visible";
|
||||
tooltip.style.visibility = "hidden";
|
||||
tooltip.style.whiteSpace = "nowrap";
|
||||
tooltip.style.zIndex = "1000";
|
||||
document.body.appendChild(tooltip);
|
||||
@@ -151,7 +151,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
const url = "http://localhost:8080/api/result/{{ .PollId }}"
|
||||
const url = "/api/result/{{ .PollId }}"
|
||||
|
||||
fetch(url, {method: "GET"})
|
||||
.then(response => {
|
||||
|
||||
Reference in New Issue
Block a user