Skip to content

Commit 88cd0af

Browse files
committed
Add Dockerfile
1 parent dfc7e95 commit 88cd0af

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM golang:1.23.4-alpine
2+
3+
WORKDIR /app
4+
5+
COPY go.mod .
6+
COPY go.sum .
7+
RUN go mod download
8+
9+
COPY *.go .
10+
COPY store/*.go store/
11+
COPY schema.sql .
12+
RUN go build -o clidle .
13+
14+
FROM scratch
15+
16+
COPY --from=0 /app/clidle .
17+
18+
ENV CLICOLOR_FORCE=1
19+
ENV CLIDLE_DATA_DIR=/opt/clidle/data
20+
CMD ["./clidle", "-serve", "0.0.0.0:22"]

main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
var (
2828
// pathClidle is the path to the local data directory.
2929
// This is usually set to ~/.local/share/clidle on most UNIX systems.
30-
pathClidle = filepath.Join(xdg.DataHome, "clidle")
31-
pathStore = filepath.Join(pathClidle, "clidle.db")
32-
pathHostKey = filepath.Join(pathClidle, "hostkey")
30+
pathClidle string
31+
pathStore string
32+
pathHostKey string
3333

3434
//go:embed schema.sql
3535
schemaSQL string
@@ -41,6 +41,16 @@ var (
4141
}
4242
)
4343

44+
func init() {
45+
pathClidle = os.Getenv("CLIDLE_DATA_DIR")
46+
if pathClidle == "" {
47+
pathClidle = filepath.Join(xdg.DataHome, "clidle")
48+
}
49+
50+
pathStore = filepath.Join(pathClidle, "clidle.db")
51+
pathHostKey = filepath.Join(pathClidle, "hostkey")
52+
}
53+
4454
func main() {
4555
flagServe := flag.String("serve", "", "Spawns an SSH server on the given address (format: 0.0.0.0:1337)")
4656
flag.Parse()

0 commit comments

Comments
 (0)