feat: Add Dockerfile to build and containerize the application
ci/woodpecker/push/build Pipeline was successful
Details
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:
parent
7aa02a1aa2
commit
e263732e3c
|
@ -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
|
|
@ -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"]
|
3
main.go
3
main.go
|
@ -89,7 +89,8 @@ func Ping(url string) (int, time.Duration, error) {
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Load config
|
// 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 {
|
if err != nil {
|
||||||
log.Fatalf("Error loading config: %s", err)
|
log.Fatalf("Error loading config: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue