feat: docker
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.git
|
||||||
|
healthr
|
||||||
|
healthr.db
|
||||||
17
Containerfile
Normal file
17
Containerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM golang:alpine AS backend_build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY go.mod ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go build -o /healthr
|
||||||
|
|
||||||
|
FROM alpine:edge AS backend
|
||||||
|
|
||||||
|
COPY --from=backend_build /healthr /healthr
|
||||||
|
|
||||||
|
EXPOSE 8090
|
||||||
|
|
||||||
|
CMD [ "/healthr" ]
|
||||||
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
healthr:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Containerfile
|
||||||
|
ports:
|
||||||
|
- 8090:8090
|
||||||
7
main.go
7
main.go
@@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var db Database = &SqliteDatabase{}
|
var db Database = &SqliteDatabase{}
|
||||||
@@ -9,5 +12,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("There was an error initializing the database %w", err)
|
log.Fatal("There was an error initializing the database %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("Starting healthr webserver.")
|
||||||
webServer(db)
|
webServer(db)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user