diff --git a/.dockerignore b/.dockerignore index a921d5b98..c851fe583 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,5 @@ target/ bin/ docker/ +frontend/node_modules/ +frontend/build/ \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index bf157b31a..493fab18c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && \ apt-get install pkg-config musl-tools libssl-dev RUN rustup update -ENV RUSTFLAGS='-C target-feature=+crt-static' +ENV RUSTFLAGS='--remap-path-prefix $HOME=~ -C target-feature=+crt-static' COPY . /src WORKDIR /src @@ -13,6 +13,22 @@ WORKDIR /src RUN rustup target add x86_64-unknown-linux-musl RUN cargo build --target x86_64-unknown-linux-musl --release +FROM node:lts as node-build + +ENV NODE_OPTIONS=--openssl-legacy-provider + +COPY ./frontend /app +WORKDIR /app + +RUN yarn install \ + --prefer-offline \ + --frozen-lockfile \ + --non-interactive \ + --production=false + +RUN yarn build + +RUN rm -rf node_modules # Final container FROM scratch @@ -22,7 +38,9 @@ COPY --from=rust-build /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=rust-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=rust-build /src/target/x86_64-unknown-linux-musl/release/m3u-filter /m3u-filter -COPY ./config /config +COPY --from=node-build /app/build /web +# config should be mounted as volume +# COPY ./config /config ENTRYPOINT ["/m3u-filter"] CMD ["-s", "-p", "/config"] diff --git a/docker/Dockerfile-manual b/docker/Dockerfile-manual new file mode 100644 index 000000000..2450fd90c --- /dev/null +++ b/docker/Dockerfile-manual @@ -0,0 +1,13 @@ +FROM gcr.io/distroless/base-debian12 as build + + +FROM scratch +WORKDIR / + +COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +COPY ./m3u-filter / +COPY ./web /web + +CMD ["./m3u-filter", "-s", "-p", "/config"] diff --git a/docker/README.md b/docker/README.md index 5c1a597d5..f5a2d5a0d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,10 +1,29 @@ -# Dockerize -To dockerize m3u-filter, you need to compile a static build. -The static build can creted with `bin\build_lin_static.sh`. -Description of static binary compiling is in the main `README.md` +# Build docker image +Change into the root directory and run: -To create a docker image type: -`docker build -t m3u-filter .` -You have to copy all the needed files (look at the Dockerfile) into the current directory. +```shell +docker build --rm -f docker/Dockerfile -t m3u-filter . +``` + +This will build the complete project and create a docker image. To start the container, you can use the `docker-compose.yml` +But you need to change `image: ghcr.io/euzu/m3u-filter:latest` to `image: m3u-filter` + +# Manual docker image + +You want to build the binary and web folder manually and create a docker image. + +To dockerize m3u-filter, you need to compile a static build. +The static build can created with `bin\build_lin_static.sh`. +Description of static binary compiling is in the main `README.md` + +Then you need to compile the frontend with `yarn build` + +Change into the `docker` directory and copy all the needed files (look at the Dockerfile) into the current directory. + +To create a docker image type: +`docker -f Dockerfile-manual build -t m3u-filter .` + +To start the container, you can use the `docker-compose.yml` +But you need to change `image: ghcr.io/euzu/m3u-filter:latest` to `image: m3u-filter`