Skip to content

Commit

Permalink
Make docker image smaller, add SHELLIP configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ngn13 committed Feb 24, 2024
1 parent 99696d2 commit 89722b9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.6
FROM golang:1.21.6 as build

WORKDIR /app

Expand All @@ -13,9 +13,13 @@ COPY util ./util
COPY views ./views

EXPOSE 5566
RUN go build .
RUN CGO_ENABLED=0 go build .

FROM alpine as main
COPY --from=build /app /app

ARG PASSWORD
ENV PASSWORD $PASSWORD
WORKDIR /app

ENTRYPOINT ["/app/ezcat"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ docker run --rm --network host \
or you can download the latest binary from the [releases tab](https://github.com/ngn13/ezcat/releases),
extract it with `tar` and then copy it to somewhere in your `PATH`.

By default ezcat will try to detect your interface IP address (giving priority to tunnel interfaces).
If you want set this IP address to something else by default, you can use the `SHELLIP` environment variable:
```
docker run --rm --network host \
-e PASSWORD=securepassword \
-e SHELLIP=10.10.10.15 \
ghcr.io/ngn13/ezcat
```

---

### ⚒️ Build
Expand Down
6 changes: 6 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"math/rand"
"net"
"os"
"strings"

"github.com/gofiber/fiber/v2"
Expand Down Expand Up @@ -78,6 +79,11 @@ func GetAddr(addrs []net.Addr) string {
}

func GetIP() string {
enip := os.Getenv("SHELLIP")
if enip != "" {
return enip
}

ip := "127.0.0.1"
foundtun := false
ifs, err := net.Interfaces()
Expand Down

0 comments on commit 89722b9

Please sign in to comment.