Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Jan 5, 2025
1 parent dfc7e95 commit 88cd0af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.23.4-alpine

WORKDIR /app

COPY go.mod .
COPY go.sum .
RUN go mod download

COPY *.go .
COPY store/*.go store/
COPY schema.sql .
RUN go build -o clidle .

FROM scratch

COPY --from=0 /app/clidle .

ENV CLICOLOR_FORCE=1
ENV CLIDLE_DATA_DIR=/opt/clidle/data
CMD ["./clidle", "-serve", "0.0.0.0:22"]
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
var (
// pathClidle is the path to the local data directory.
// This is usually set to ~/.local/share/clidle on most UNIX systems.
pathClidle = filepath.Join(xdg.DataHome, "clidle")
pathStore = filepath.Join(pathClidle, "clidle.db")
pathHostKey = filepath.Join(pathClidle, "hostkey")
pathClidle string
pathStore string
pathHostKey string

//go:embed schema.sql
schemaSQL string
Expand All @@ -41,6 +41,16 @@ var (
}
)

func init() {
pathClidle = os.Getenv("CLIDLE_DATA_DIR")
if pathClidle == "" {
pathClidle = filepath.Join(xdg.DataHome, "clidle")
}

pathStore = filepath.Join(pathClidle, "clidle.db")
pathHostKey = filepath.Join(pathClidle, "hostkey")
}

func main() {
flagServe := flag.String("serve", "", "Spawns an SSH server on the given address (format: 0.0.0.0:1337)")
flag.Parse()
Expand Down

0 comments on commit 88cd0af

Please sign in to comment.