From 4c0bc9d05ce04721568cb34c8e6796ece8112486 Mon Sep 17 00:00:00 2001 From: Bernd Storath <999999bst@gmail.com> Date: Mon, 5 Aug 2024 11:39:20 +0200 Subject: [PATCH] add docker dev script --- Dockerfile-dev | 56 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.dev.yml | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Dockerfile-dev diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 00000000..729d4633 --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,56 @@ +# As a workaround we have to build on nodejs 18 +# nodejs 20 hangs on build with armv6/armv7 +FROM docker.io/library/node:18-alpine AS build_node_modules + +# Install pnpm +RUN corepack enable pnpm + +# Copy Web UI +COPY src /app +WORKDIR /app +RUN pnpm install + +# Build UI +RUN pnpm build + +RUN mv node_modules /node_modules + +# Copy build result to a new image. +# This saves a lot of disk space. +FROM docker.io/library/node:20-alpine +HEALTHCHECK CMD /usr/bin/timeout 5s /bin/sh -c "/usr/bin/wg show | /bin/grep -q interface || exit 1" --interval=1m --timeout=5s --retries=3 +COPY --from=build_node_modules /app /app + +# Move node_modules one directory up, so during development +# we don't have to mount it in a volume. +# This results in much faster reloading! +# +# Also, some node_modules might be native, and +# the architecture & OS of your development machine might differ +# than what runs inside of docker. +COPY --from=build_node_modules /node_modules /node_modules + +# Copy the needed wg-password scripts +COPY --from=build_node_modules /app/wgpw.sh /bin/wgpw +RUN chmod +x /bin/wgpw + +# Install Linux packages +RUN apk add --no-cache \ + dpkg \ + dumb-init \ + iptables \ + iptables-legacy \ + wireguard-tools + +# Install pnpm +RUN corepack enable pnpm + +# Use iptables-legacy +RUN update-alternatives --install /sbin/iptables iptables /sbin/iptables-legacy 10 --slave /sbin/iptables-restore iptables-restore /sbin/iptables-legacy-restore --slave /sbin/iptables-save iptables-save /sbin/iptables-legacy-save + +# Set Environment +ENV DEBUG=Server,WireGuard +ENV PORT=51821 + +# Run Web UI +WORKDIR /app \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index f33aae6d..ad7f6e38 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,7 +1,7 @@ services: wg-easy: build: - dockerfile: ./Dockerfile + dockerfile: ./Dockerfile-dev command: pnpm run dev volumes: - ./src/:/app/