diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1fd6f59 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM golang:1.16 as builder +WORKDIR /src +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN go build -o apollo ./cmd/ + +FROM alpine + +# Taken from https://github.com/wernight/docker-youtube-dl +RUN apk add --no-cache ca-certificates curl dumb-init ffmpeg gnupg python3 libc6-compat +RUN curl -Lo /usr/local/bin/youtube-dl https://yt-dl.org/downloads/latest/youtube-dl && \ + curl -Lo youtube-dl.sig https://yt-dl.org/downloads/latest/youtube-dl.sig && \ + gpg --keyserver keyserver.ubuntu.com --recv-keys '7D33D762FD6C35130481347FDB4B54CBA4826A18' && \ + gpg --keyserver keyserver.ubuntu.com --recv-keys 'ED7F5BF46B3BBED81C87368E2C393E0F18A9236D' && \ + gpg --verify youtube-dl.sig /usr/local/bin/youtube-dl && \ + chmod a+rx /usr/local/bin/youtube-dl && \ + ln -s /usr/bin/python3 /usr/bin/python && \ + rm youtube-dl.sig && \ + apk del curl gnupg +WORKDIR /etc/apollo +RUN mkdir data +COPY --from=builder /src/apollo /bin/apollo +COPY --from=builder /src/static/ ./static/ +EXPOSE 8993 +ENTRYPOINT ["/bin/apollo"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..88cd679 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.6' + +services: + app: + build: . + environment: + PASSWORD: my_password + ports: + - 8993:8993 \ No newline at end of file diff --git a/pkg/apollo/server.go b/pkg/apollo/server.go index 9f6af2a..cdb6301 100644 --- a/pkg/apollo/server.go +++ b/pkg/apollo/server.go @@ -127,8 +127,7 @@ func authenticatePassword(w http.ResponseWriter, r *http.Request) { } func isValidPassword(password string) bool { - err := godotenv.Load() - check(err) + godotenv.Load() truePass := os.Getenv("PASSWORD") return truePass == password }