From bef9b6d46db7864a908498649f63cb1937533aa2 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Tue, 26 Mar 2024 10:07:04 -0400 Subject: [PATCH] feat: add docker build --- .dockerignore | 7 +++++++ .env.example | 2 ++ Dockerfile | 21 +++++++++++++++++++++ vite.config.ts | 1 + 4 files changed, 31 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6bc022e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.dockerignore +Dockerfile + +/.cache +/build +.env diff --git a/.env.example b/.env.example index a108d01..e765522 100644 --- a/.env.example +++ b/.env.example @@ -5,3 +5,5 @@ OIDC_CLIENT_ID=headscale OIDC_ISSUER=https://sso.example.com OIDC_CLIENT_SECRET=super_secret_client_secret DISABLE_API_KEY_LOGIN=true +HOST=0.0.0.0 +PORT=3000 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ee7fee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:20-alpine AS build +WORKDIR /app + +RUN npm install -g pnpm +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +COPY . . +RUN pnpm run build +RUN pnpm prune --prod + +FROM node:20-alpine +WORKDIR /app +COPY --from=build /app/build /app +COPY --from=build /app/node_modules /app/node_modules +RUN echo '{"type":"module"}' > /app/package.json + +EXPOSE 3000 +ENV NODE_ENV=production +ENV HOST=0.0.0.0 +CMD [ "node_modules/.bin/remix-serve", "server/index.js" ] diff --git a/vite.config.ts b/vite.config.ts index a59ba34..3625644 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,7 @@ import tsconfigPaths from 'vite-tsconfig-paths' installGlobals() export default defineConfig({ + base: '/admin/', plugins: [remix({ basename: '/admin' }), tsconfigPaths()]