diff --git a/.dockerignore b/.dockerignore index 0979a6c..7a1537b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ -**/node_modules/** +.idea +node_modules diff --git a/Dockerfile b/Dockerfile index c04c8c6..9c0221e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,53 @@ -FROM docker.io/library/node:alpine AS deps +FROM node:alpine as base WORKDIR /app +ENV TZ=UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +COPY --from=golang:1.20-alpine /usr/local/go/ /usr/local/go/ +COPY --from=gogost/gost:3.0.0-rc8 /bin/gost /usr/local/bin/gost + +RUN apk add -U --no-cache \ + iproute2 iptables net-tools \ + screen vim curl bash \ + wireguard-tools \ + dumb-init \ + tor \ + redis + + +FROM node:alpine as builder +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm install + +ENV NODE_ENV=production +COPY /src/ . + +RUN npm run build + + +FROM base +WORKDIR /app + +ENV NODE_ENV=production + LABEL Maintainer="Shahrad Elahi " +COPY /config/torrc /etc/tor/torrc -COPY src/package.json src/pnpm-lock.yaml ./ -RUN npm i -g pnpm -RUN pnpm i --frozen-lockfile +COPY --from=builder /app/.build ./.build +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/next.config.js ./next.config.js +COPY --from=builder /app/public ./public -# Copy build result to a new image. -# This saves a lot of disk space. -FROM docker.io/library/node:alpine as runner -WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm install -# 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 src/ /app/ -COPY --from=deps /opt/app/node_modules ./node_modules - -# Install Linux packages -RUN apk add -U --no-cache \ - wireguard-tools \ - dumb-init \ - iptables - -# Expose UI Ports EXPOSE 3000/tcp -# Set Environment -ENV DEBUG=Server,WireGuard +COPY docker-entrypoint.sh /usr/bin/entrypoint +ENTRYPOINT ["/usr/bin/entrypoint"] -# Run Web UI -WORKDIR /app -CMD ["/usr/bin/dumb-init", "node", "server.js"] +CMD ["npm", "run", "start"] diff --git a/Dockerfile-Dev b/Dockerfile-Dev index 0950936..61205ad 100644 --- a/Dockerfile-Dev +++ b/Dockerfile-Dev @@ -1,14 +1,11 @@ -FROM docker.io/library/node:alpine +FROM node:alpine as base WORKDIR /app ENV TZ=UTC RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone COPY --from=golang:1.20-alpine /usr/local/go/ /usr/local/go/ -COPY --from=gogost/gost /bin/gost /usr/local/bin/gost - -COPY /src/ /app/ -COPY /config/torrc /etc/tor/torrc +COPY --from=gogost/gost:3.0.0-rc8 /bin/gost /usr/local/bin/gost RUN apk add -U --no-cache \ iproute2 iptables net-tools \ @@ -18,9 +15,16 @@ RUN apk add -U --no-cache \ tor \ redis + +FROM base +WORKDIR /app + +COPY /src/ /app/ +COPY /config/torrc /etc/tor/torrc + EXPOSE 3000/tcp -COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -ENTRYPOINT ["docker-entrypoint.sh"] +COPY docker-entrypoint.sh /usr/bin/entrypoint +ENTRYPOINT ["/usr/bin/entrypoint"] CMD ["npm", "run", "dev"] diff --git a/src/ui/Modal/CreateClientModal.tsx b/src/ui/Modal/CreateClientModal.tsx index 3509c5a..fa5eade 100644 --- a/src/ui/Modal/CreateClientModal.tsx +++ b/src/ui/Modal/CreateClientModal.tsx @@ -7,12 +7,10 @@ import useSWRMutation from "swr/mutation"; import { AddressSchema, DnsSchema, MtuSchema, NameSchema, PortSchema, TypeSchema } from "@lib/schemas/WireGuard"; import { zodErrorMessage } from "@lib/zod"; -export type CreateClientModalProps = {} - const CreateClientModal = React.forwardRef< SmartModalRef, - CreateClientModalProps ->((props, ref) => { + {} +>((_, ref) => { const [ notificationApi, contextHolder ] = notification.useNotification() diff --git a/src/ui/pages/PageHeader.tsx b/src/ui/pages/PageHeader.tsx index 42ee78e..aa23b98 100644 --- a/src/ui/pages/PageHeader.tsx +++ b/src/ui/pages/PageHeader.tsx @@ -20,7 +20,7 @@ export default function PageHeader(props: PageHeaderProps) {