add Dockerfile and docker-compose
Marco Andronaco andronacomarco@gmail.com
Tue, 19 Dec 2023 13:19:14 +0100
6 files changed,
109 insertions(+),
2 deletions(-)
A
Dockerfile
@@ -0,0 +1,33 @@
+# syntax=docker/dockerfile:1 + +FROM golang:alpine AS builder + +RUN apk add --no-cache build-base + +WORKDIR /build + +# Download Go modules +COPY go.mod go.sum ./ +RUN go mod download + +# Transfer source code +COPY templates /dist/templates +COPY templates ./templates +COPY invidious ./invidious +COPY *.go ./ + +# Build +RUN CGO_ENABLED=1 go build -ldflags='-s -w' -trimpath -o /dist/app +RUN ldd /dist/app | tr -s [:blank:] '\n' | grep ^/ | xargs -I % install -D % /dist/% +RUN ln -s ld-musl-x86_64.so.1 /dist/lib/libc.musl-x86_64.so.1 + +# Test +FROM build-stage AS run-test-stage +RUN go test -v ./... + +FROM scratch AS build-release-stage + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /dist / + +ENTRYPOINT ["/app"]
M
README.md
→
README.md
@@ -6,9 +6,26 @@ Replace `www.youtube.com` or `youtu.be` with `y.outube.duckdns.org` to fix embeds for short videos.
https://github.com/BiRabittoh/FixYouTube/assets/26506860/e1ad5397-41c8-4073-9b3e-598c66241255 -## Instructions +## Instructions (Docker) + +### With reverse proxy +Copy the template config file and make your adjustments. My configuration is based on [DuckDNS](http://duckdns.org/) but you can use whatever provider you find [here](https://docs.linuxserver.io/general/swag#docker-compose). + +``` +cp docker/swag.env.example docker/swag.env +nano docker/swag.env +``` + +Finally: `docker-compose up -d`. -### Debug +### Without reverse proxy +Simply run: ``` +docker run -d -p 3000:3000 --name fixyoutube-go --restart unless-stopped ghcr.io/birabittoh/fixyoutube-go:main +``` + +## Instructions (local) +``` +go test -v ./... go run . ```
A
docker-compose.yaml
@@ -0,0 +1,20 @@
+services: + app: + build: . + image: ghcr.io/birabittoh/fixyoutube-go:main + container_name: fixyoutube-go + restart: unless-stopped + swag: + image: ghcr.io/linuxserver/swag + container_name: swag + cap_add: + - NET_ADMIN + env_file: + - docker/swag.env + volumes: + #- /etc/config/swag:/config + - ./docker/fixyoutube.subdomain.conf:/config/nginx/proxy-confs/fixyoutube.subdomain.conf:ro + ports: + - 443:443 + - 80:80 + restart: unless-stopped
A
docker/fixyoutube.subdomain.conf
@@ -0,0 +1,22 @@
+# make sure that your app container is named fixyoutube +# make sure that your dns has a cname set for fixyoutube + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name y.*; # change your subdomain here + + include /config/nginx/ssl.conf; + + client_max_body_size 0; + + location / { + include /config/nginx/proxy.conf; + include /config/nginx/resolver.conf; + set $upstream_app fixyoutube; + set $upstream_port 3000; + set $upstream_proto http; + proxy_pass $upstream_proto://$upstream_app:$upstream_port; + } +}
A
docker/swag.env.example
@@ -0,0 +1,14 @@
+PUID=1000 +PGID=1000 +#valid TZs at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +TZ=Etc/UTC +URL=domain.duckdns.org +SUBDOMAINS=wildcard +VALIDATION=duckdns +CERTPROVIDER= #optional +DNSPLUGIN= #optional +DUCKDNSTOKEN=abc123ab-c123-abc1-23ab-c123abc123ab +EMAIL=your@email.com +ONLY_SUBDOMAINS=false +EXTRA_DOMAINS=y +STAGING=false