Skip to content

Commit 1b7836b

Browse files
committed
Generate config file for server if not found
1 parent c99330c commit 1b7836b

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@ COPY . .
99
RUN go mod download
1010
RUN go build -ldflags "-s -w -X 'go-public/common.Version=$(cat VERSION)'" -o go-public
1111

12-
FROM alpine
13-
14-
RUN apk update \
15-
&& apk upgrade \
16-
&& apk add --no-cache ca-certificates tzdata \
17-
&& update-ca-certificates 2>/dev/null || true
12+
FROM scratch
1813

1914
COPY --from=builder /build/go-public /
20-
EXPOSE 6871
15+
EXPOSE 7891
2116
EXPOSE 8080
2217
WORKDIR /app
23-
ENTRYPOINT ["/go-public"]
24-
18+
ENTRYPOINT ["/go-public"]

common/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ func LoadConfigFile(isServer bool) {
7171
if err != nil {
7272
println("Config file `" + configPath + "` not found.")
7373
if isServer {
74-
println("Use `go-public init server` to initialize a config file.")
74+
println("Generating a new config file...")
75+
InitConfigFile(true)
76+
configBytes, _ = os.ReadFile(configPath)
7577
} else {
7678
println("Use `go-public init client` to initialize a config file.")
79+
os.Exit(1)
7780
}
78-
os.Exit(1)
7981
}
8082
if isServer {
8183
err = yaml.Unmarshal(configBytes, &ServerConfig)

0 commit comments

Comments
 (0)