-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Make docker compose prod and add dev extension (#175)
* Add docker-compose extension * Add tests and .husky to frontend dockerignore * Set app envs to production in extension * chore: Move EXPOSE to start in pnpm dev Dockerfile * style: Drop extra line in docker-compose * build: Add multi-stage prod Dockerfile for next.js * build: Configure next.config.mjs for prod * fix: Use pnpm start in prod Dockerfile * chore: version deprecated in docker compose * build: Support SSL disable in local prod * build: Drop nextjs output traces * build(fix): Missing package-lock file * docs: Update prod extension module docs * build(ui): Add @types/react-syntax-highlighter 15.5.0 * chore: Run pnpm format:fix * refactor: Remove unused util function * chore: Fix linter errors * fix(ui): Fix DOM nesting errors * chore(ui): Fix lint warnings * style(ui): Fix shadcn components linter warnings * fix: Missing build env vars * fix: WorkflowItem ref in playbooks * Add NEXT_SERVER_API_URL Co-authored-by: Daryl Lim <daryllimyt@users.noreply.github.com> * Add suspence boundary to server-side pages * fix(ui): Graceful error handling for unable to load workflows or playbooks in server component * Add Dockerfiles to dockerignore * fix: Add missing generateBuildId * feat: Switch docker-compose prod with dev --------- Signed-off-by: Chris Lo <46541035+topher-lo@users.noreply.github.com> Co-authored-by: Daryl Lim <5508348+daryllimyt@users.noreply.github.com> Co-authored-by: Daryl Lim <daryllimyt@users.noreply.github.com>
- Loading branch information
1 parent
64440dc
commit df62af6
Showing
55 changed files
with
7,131 additions
and
4,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Non-development docker compose extension file | ||
# - Removes all volume bindings | ||
# - Uses the multi-stage frontend Dockerfile | ||
# - Changes env vars to production | ||
services: | ||
api: | ||
volumes: | ||
- ./tracecat:/app/tracecat | ||
- app-storage:/var/lib/tracecat | ||
|
||
worker: | ||
volumes: | ||
- ./tracecat:/app/tracecat | ||
- app-storage:/var/lib/tracecat | ||
|
||
frontend: | ||
build: | ||
context: ./frontend | ||
dockerfile: Dockerfile | ||
args: | ||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL} | ||
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL} | ||
NEXT_PUBLIC_DISABLE_AUTH: ${TRACECAT__DISABLE_AUTH} | ||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY} # Sensitive | ||
NEXT_SERVER_API_URL: ${NEXT_SERVER_API_URL} | ||
NODE_ENV: ${NODE_ENV} | ||
volumes: | ||
- ./frontend/src:/app/src | ||
- ./frontend/.next:/app/.next | ||
- ./frontend/node_modules:/app/node_modules | ||
|
||
postgres_db: | ||
volumes: | ||
- db-storage:/var/lib/postgresql/data | ||
|
||
volumes: | ||
app-storage: | ||
db-storage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
node_modules | ||
build | ||
.husky | ||
.next | ||
build | ||
node_modules | ||
tests | ||
# Ignore Dockerfiles | ||
Dockerfile.prod | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
# For development only | ||
|
||
FROM node:21-slim AS base | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
RUN corepack enable | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
|
||
EXPOSE 3000 | ||
CMD [ "pnpm", "dev" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
FROM node:22-alpine AS deps | ||
WORKDIR /app | ||
|
||
RUN apk add --no-cache libc6-compat | ||
|
||
# Copy only the files needed to install dependencies | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
|
||
# Install dependencies with pnpm | ||
RUN corepack enable pnpm && pnpm i --frozen-lockfile | ||
|
||
FROM node:22-alpine AS builder | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
|
||
ARG NEXT_PUBLIC_APP_URL | ||
ARG NEXT_PUBLIC_API_URL | ||
ARG NEXT_PUBLIC_DISABLE_AUTH | ||
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | ||
ARG NEXT_SERVER_API_URL | ||
|
||
ENV NEXT_PUBLIC_APP_URL $NEXT_PUBLIC_APP_URL | ||
ENV NEXT_PUBLIC_API_URL $NEXT_PUBLIC_API_URL | ||
ENV NEXT_PUBLIC_DISABLE_AUTH $NEXT_PUBLIC_DISABLE_AUTH | ||
ENV NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY $NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | ||
ENV NEXT_SERVER_API_URL $NEXT_SERVER_API_URL | ||
|
||
COPY --from=deps /app/node_modules ./node_modules | ||
|
||
# Copy the rest of the files | ||
COPY . . | ||
|
||
# Run build with the preferred package manager | ||
RUN corepack enable pnpm && pnpm build | ||
|
||
FROM node:22-alpine AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
|
||
# Add nextjs user | ||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
# TODO: Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next | ||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["/app/node_modules/.bin/next", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: false, | ||
|
||
const nextConfig = {} | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
nextConfig.reactStrictMode = false | ||
} else { | ||
nextConfig.reactStrictMode = true | ||
nextConfig.output = "standalone" | ||
generateBuildId: async () => { | ||
// Return a unique identifier for each build. | ||
return Date.now().toString() | ||
} | ||
} | ||
|
||
export default nextConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.