Add Docker

This commit is contained in:
vlnst
2024-11-25 16:32:06 +03:00
parent 2ed5d08bbc
commit 58a249f149
4 changed files with 43 additions and 1 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
LICENSE
README.md

1
.gitignore vendored
View File

@@ -5,4 +5,3 @@ package-lock.json
fly.toml
*.fiber.gz
soundcloak.json
Dockerfile

28
Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
ARG GO_VERSION=1.21.3
ARG NODE_VERSION=bookworm
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
ARG TARGETOS
ARG TARGETARCH
WORKDIR /build
COPY . .
RUN go install github.com/a-h/templ/cmd/templ@latest && \
templ generate && \
CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -ldflags "-s -w -extldflags '-static'" -o ./app
FROM node:${NODE_VERSION} AS node
WORKDIR /hls.js
COPY --from=build /build/package.json ./
RUN npm i
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /build/assets /assets
COPY --from=build /build/app /app
COPY --from=node /hls.js/node_modules /node_modules
EXPOSE 4664
ENTRYPOINT ["/app"]

13
compose.yaml Normal file
View File

@@ -0,0 +1,13 @@
services:
soundcloak:
container_name: soundcloak
restart: unless-stopped
build: .
ports:
- "127.0.0.1:4664:4664"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
volumes:
- ./soundcloak.json:/soundcloak.json