diff --git a/Dockerfile b/Dockerfile index 6745e4c..1efd4c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,9 @@ COPY --from=chriswayg/tor-alpine:latest /usr/local/bin/obfs4proxy /usr/local/bin COPY --from=chriswayg/tor-alpine:latest /usr/local/bin/meek-server /usr/local/bin/meek-server # Update and upgrade packages -RUN apk update && apk upgrade \ +RUN apk update && apk upgrade &&\ # Install required packages - && apk add -U --no-cache \ + apk add -U --no-cache \ iproute2 iptables net-tools \ screen curl bash \ wireguard-tools \ @@ -23,14 +23,21 @@ RUN apk update && apk upgrade \ COPY /config/torrc /etc/tor/torrc +# Copy user scripts COPY /bin /usr/local/bin RUN chmod -R +x /usr/local/bin COPY web/package.json web/pnpm-lock.yaml ./ +# Base env +ENV ORIGIN=http://127.0.0.1:3000 +ENV PROTOCOL_HEADER=x-forwarded-proto +ENV HOST_HEADER=x-forwarded-host + FROM base AS build +# Setup Pnpm - Pnpm only used for build stage ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable @@ -51,25 +58,30 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile FROM base AS release +# Copy the goods from the build stage COPY --from=build /tmp/node_modules node_modules COPY --from=build /tmp/build build ENV NODE_ENV=production ENV LOG_LEVEL=error +# Setup entrypoint COPY docker-entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] +# Healthcheck HEALTHCHECK --interval=60s --timeout=3s --start-period=20s --retries=3 \ CMD curl -f http://127.0.0.1:3000/api/health || exit 1 +# Fix permissions RUN mkdir -p /data && chmod 700 /data RUN mkdir -p /etc/torrc.d && chmod -R 400 /etc/torrc.d RUN mkdir -p /var/vlogs && touch /var/vlogs/web && chmod -R 600 /var/vlogs +# Volumes VOLUME ["/etc/torrc.d", "/data", "/var/vlogs"] -# run the app +# Run the app EXPOSE 3000/tcp CMD [ "npm", "run", "start" ] diff --git a/Dockerfile-Dev b/Dockerfile-Dev index c347cd4..484f29d 100644 --- a/Dockerfile-Dev +++ b/Dockerfile-Dev @@ -9,9 +9,9 @@ COPY --from=chriswayg/tor-alpine:latest /usr/local/bin/obfs4proxy /usr/local/bin COPY --from=chriswayg/tor-alpine:latest /usr/local/bin/meek-server /usr/local/bin/meek-server # Update and upgrade packages -RUN apk update && apk upgrade \ +RUN apk update && apk upgrade &&\ # Install required packages - && apk add -U --no-cache \ + apk add -U --no-cache \ iproute2 iptables net-tools \ screen vim curl bash \ wireguard-tools \ @@ -21,22 +21,31 @@ RUN apk update && apk upgrade \ # Clear APK cache rm -rf /var/cache/apk/* +# Copy Tor Configs COPY /config/torrc /etc/tor/torrc COPY /config/obfs4-bridges.conf /etc/torrc.d/obfs4-bridges.conf +# Copy user scripts COPY /bin /usr/local/bin RUN chmod -R +x /usr/local/bin - -FROM base AS runner - +# Setup Pnpm ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable +# Base env +ENV ORIGIN=http://127.0.0.1:5173,http://localhost:5173 +ENV PROTOCOL_HEADER=x-forwarded-proto +ENV HOST_HEADER=x-forwarded-host + + +FROM base AS runner + ENV NODE_ENV=development ENV LOG_LEVEL=debug + COPY docker-entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 7f1efbc..8021539 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -7,8 +7,8 @@ services: ports: - "5173:5173" environment: - - UI_PASSWORD=password - WG_HOST=192.168.1.102 + - UI_PASSWORD=password - TOR_SOCKS5_PROXY=host.docker.internal:8080 extra_hosts: - "host.docker.internal:host-gateway" diff --git a/docker-compose.yml b/docker-compose.yml index 7d8eb00..9131bf3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,16 +4,19 @@ services: environment: # ⚠️ Required: # Make sure change this to your host's public address - - WG_HOST=raspberrypi.local + - WG_HOST=localhost + # ⚠️ Required: + # You can use `openssl rand -base64 8` to generate a secure password + - UI_PASSWORD=super-secret-password - image: shahradel/wireadmin - container_name: wireadmin + image: wireadmin + container_name: litehex/wireadmin + restart: unless-stopped volumes: - - redis-data:/data + - persist-data:/data ports: - "51820:51820/udp" - "3000:3000/tcp" - restart: unless-stopped cap_add: - NET_ADMIN - SYS_MODULE @@ -22,5 +25,5 @@ services: - net.ipv4.conf.all.src_valid_mark=1 volumes: - redis-data: + persist-data: driver: local \ No newline at end of file diff --git a/package.json b/package.json index 19a78a7..8f9b6d7 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,10 @@ "version": "1.0.0", "description": "", "scripts": { - "dev:image": "DOCKER_BUILDKIT=1 docker build --tag wireadmin -f Dockerfile-Dev .", - "dev": "docker compose rm -fsv && docker compose -f docker-compose.yml -f docker-compose.dev.yml up" + "dev": "docker compose rm -fsv && docker compose -f docker-compose.yml -f docker-compose.dev.yml up", + "dev:image": "docker buildx build --tag wireadmin -f Dockerfile-Dev .", + "build": "docker buildx build --tag wireadmin .", + "start": "docker compose rm -fsv && docker compose -f docker-compose.yml up" }, "keywords": [], "author": "Shahrad Elahi ", diff --git a/web/package.json b/web/package.json index 86e9b0b..8e80738 100644 --- a/web/package.json +++ b/web/package.json @@ -3,15 +3,15 @@ "version": "1.1.2", "type": "module", "scripts": { - "dev": "NODE_ENV=development vite dev", - "build": "NODE_ENV=build vite build", + "dev": "vite dev", + "build": "vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "test": "mocha", "check:format": "prettier --check .", "format": "prettier --write .", - "start": "NODE_ENV=production node ./build/index.js" + "start": "node ./build/index.js" }, "packageManager": "pnpm@8.15.0", "engines": {