feat: Add Dockerfile to build and containerize the application
ci/woodpecker/push/build Pipeline was successful Details

* Add basic Dockerfile
* Add build CI pipeline
* Some quick adaptations to the config file location
This commit is contained in:
Aire-One 2024-08-23 01:02:33 +02:00
parent 7aa02a1aa2
commit e263732e3c
4 changed files with 47 additions and 1 deletions

20
.woodpecker/build.yaml Normal file
View File

@ -0,0 +1,20 @@
---
when:
branch: main
path:
- Dockerfile
- .woodpecker/build.yaml
variables:
- &buildx woodpeckerci/plugin-docker-buildx:4.2.0
- &buildx_settings
platforms: linux/amd64
steps:
dryrun:
image: *buildx
settings:
<<: *buildx_settings
dry_run: true
when:
event: pull_request

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
# syntax=docker/dockerfile:1
FROM golang:1.22.4 AS builder
WORKDIR /app
COPY go.mod go.sum main.go ./
RUN go mod download
RUN go build
FROM gcr.io/distroless/base-debian12
WORKDIR /
COPY --from=builder /app/labtime /labtime
# This is the port currently hardcoded in the application
EXPOSE 2112
# For now the config file path/name are hardcoded in the application
VOLUME ["/config"]
USER nonroot:nonroot
ENTRYPOINT ["/labtime"]

View File

@ -89,7 +89,8 @@ func Ping(url string) (int, time.Duration, error) {
func main() {
// Load config
config, err := NewConfig("config.yaml")
// TODO: Use a flag to specify the config file
config, err := NewConfig("config/config.yaml")
if err != nil {
log.Fatalf("Error loading config: %s", err)
}