Skip to content

Commit 80b4c15

Browse files
authored
Replace darkhttpd with cozystack-assets-server (#596)
fixes #602 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new custom assets server for serving static files - Replaced `darkhttpd` with a custom Go-based file server - **Improvements** - Updated base images to Alpine Linux 3.21 - Simplified container dependencies - Enhanced server configuration with command-line flags - **Infrastructure** - Rebuilt Kubernetes deployment configuration for assets service - Updated server startup parameters and container settings <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent cc5eb47 commit 80b4c15

3 files changed

Lines changed: 40 additions & 9 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"log"
6+
"net/http"
7+
"path/filepath"
8+
)
9+
10+
func main() {
11+
addr := flag.String("address", ":8123", "Address to listen on")
12+
dir := flag.String("dir", "/cozystack/assets", "Directory to serve files from")
13+
flag.Parse()
14+
15+
absDir, err := filepath.Abs(*dir)
16+
if err != nil {
17+
log.Fatalf("Error getting absolute path for %s: %v", *dir, err)
18+
}
19+
20+
fs := http.FileServer(http.Dir(absDir))
21+
http.Handle("/", fs)
22+
23+
log.Printf("Server starting on %s, serving directory %s", *addr, absDir)
24+
25+
err = http.ListenAndServe(*addr, nil)
26+
if err != nil {
27+
log.Fatalf("Server failed to start: %v", err)
28+
}
29+
}

‎packages/core/installer/images/cozystack/Dockerfile‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:alpine3.19 as k8s-await-election-builder
1+
FROM golang:alpine3.21 as k8s-await-election-builder
22

33
ARG K8S_AWAIT_ELECTION_GITREPO=https://github.com/LINBIT/k8s-await-election
44
ARG K8S_AWAIT_ELECTION_VERSION=0.4.1
@@ -13,27 +13,30 @@ RUN git clone ${K8S_AWAIT_ELECTION_GITREPO} /usr/local/go/k8s-await-election/ \
1313
&& make \
1414
&& mv ./out/k8s-await-election-${TARGETARCH} /k8s-await-election
1515

16-
FROM alpine:3.19 AS builder
16+
FROM golang:alpine3.21 as builder
1717

1818
RUN apk add --no-cache make git
1919
RUN apk add helm --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
2020

2121
COPY . /src/
2222
WORKDIR /src
2323

24+
RUN go build -o /cozystack-assets-server -ldflags '-extldflags "-static" -w -s' ./cmd/cozystack-assets-server
25+
2426
# Check that versions_map is not changed
2527
RUN make repos
2628

27-
FROM alpine:3.19
29+
FROM alpine:3.21
2830

29-
RUN apk add --no-cache make darkhttpd
31+
RUN apk add --no-cache make
3032
RUN apk add helm kubectl --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
3133

3234
COPY scripts /cozystack/scripts
3335
COPY --from=builder /src/packages/core /cozystack/packages/core
3436
COPY --from=builder /src/packages/system /cozystack/packages/system
3537
COPY --from=builder /src/_out/repos /cozystack/assets/repos
3638
COPY --from=builder /src/_out/logos /cozystack/assets/logos
39+
COPY --from=builder /cozystack-assets-server /usr/bin/cozystack-assets-server
3740
COPY --from=k8s-await-election-builder /k8s-await-election /usr/bin/k8s-await-election
3841
COPY dashboards /cozystack/assets/dashboards
3942

‎packages/core/installer/templates/cozystack.yaml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ spec:
6767
valueFrom:
6868
fieldRef:
6969
fieldPath: metadata.name
70-
- name: darkhttpd
70+
- name: assets
7171
image: "{{ .Values.cozystack.image }}"
7272
command:
73-
- /usr/bin/darkhttpd
74-
- /cozystack/assets
75-
- --port
76-
- "8123"
73+
- /usr/bin/cozystack-assets-server
74+
- "-dir=/cozystack/assets"
75+
- "-address=:8123"
7776
ports:
7877
- name: http
7978
containerPort: 8123

0 commit comments

Comments
 (0)