diff --git a/.env.example b/.env.example index 99957d59..a27871f2 100644 --- a/.env.example +++ b/.env.example @@ -3,15 +3,27 @@ NODE_ENV=development # Next Auth config: # Generate a secret with `openssl rand -base64 32`, or visit https://generate-secret.vercel.app/ -NEXTAUTH_SECRET=changeme +NEXTAUTH_SECRET=*** NEXTAUTH_URL=http://localhost:3000 # Prisma DATABASE_URL=file:./db.sqlite # External APIs: -OPENAI_API_KEY=changeme +OPENAI_API_KEY=*** # Guest Mode: -//The key NEXT_PUBLIC_GUEST_KEY should be in this format: abc,qwe,123, where each comma-separated value can be used -NEXT_PUBLIC_GUEST_KEY=changeme +The key NEXT_PUBLIC_GUEST_KEY should be in this format: abc,qwe,123, where each comma-separated value can be used +NEXT_PUBLIC_GUEST_KEY=*** + +# Websearch. Fill both of these values to enable it locally +NEXT_PUBLIC_WEB_SEARCH_ENABLED=false # Disables the ability to toggle web search +SERP_API_KEY=*** # https://serper.dev/ for an API key + +# Auth providers. Required to enable sign in, in production. Development mode uses local auth. +GOOGLE_CLIENT_ID=*** +GOOGLE_CLIENT_SECRET=*** +GITHUB_CLIENT_ID=*** +GITHUB_CLIENT_SECRET=*** +DISCORD_CLIENT_SECRET=*** +DISCORD_CLIENT_ID=*** diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 2700163b..cd3378ae 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -43,13 +43,13 @@ jobs: OPENAI_API_KEY: ${OPENAI_API_KEY} NEXT_PUBLIC_WEB_SEARCH_ENABLED: ${NEXT_PUBLIC_WEB_SEARCH_ENABLED} SERP_API_KEY: ${SERP_API_KEY} - # NEXT_PUBLIC_FF_AUTH_ENABLED: ${NEXT_PUBLIC_FF_AUTH_ENABLED} - # GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID} - # GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} - # GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} - # GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} - # DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID} - # DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET} + NEXT_PUBLIC_FF_AUTH_ENABLED: ${NEXT_PUBLIC_FF_AUTH_ENABLED} + GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID} + GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} + GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} + GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} + DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID} + DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 71b5c6fb..3cff8614 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -3,24 +3,24 @@ version: '3' services: autogpt: container_name: autogpt - # image: dogtititi/autogpt-next-web:latest - build: - context: . - dockerfile: prod.Dockerfile - args: - NEXTAUTH_URL: http://localhost:3000 - DATABASE_URL: file:./db.sqlite - OPENAI_API_KEY: ${OPENAI_API_KEY} # openai api key - NEXT_PUBLIC_WEB_SEARCH_ENABLED: true # enable web search - SERP_API_KEY: ${SERP_API_KEY} # serp api key - NEXT_PUBLIC_GUEST_KEY: 123 # guest key - # NEXT_PUBLIC_FF_AUTH_ENABLED: ${NEXT_PUBLIC_FF_AUTH_ENABLED} false # auth enable - # GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID} # google client id - # GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} # google client secret - # GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} # github client id - # GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} # github client secret - # DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID} # discord client id - # DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET} # discord client secret + image: dogtititi/autogpt-next-web:lastest + # build: + # context: . + # dockerfile: prod.Dockerfile + # args: + # NEXTAUTH_URL: http://localhost:3000 + # DATABASE_URL: file:./db.sqlite + # OPENAI_API_KEY: ${OPENAI_API_KEY} # openai api key + # NEXT_PUBLIC_WEB_SEARCH_ENABLED: ${NEXT_PUBLIC_WEB_SEARCH_ENABLED} # enable web search + # SERP_API_KEY: ${SERP_API_KEY} # serp api key + # NEXT_PUBLIC_GUEST_KEY: ${NEXT_PUBLIC_GUEST_KEY} # guest key + # NEXT_PUBLIC_FF_AUTH_ENABLED: ${NEXT_PUBLIC_FF_AUTH_ENABLED} # auth enable + # GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID} # google client id + # GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} # google client secret + # GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} # github client id + # GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} # github client secret + # DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID} # discord client id + # DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET} # discord client secret ports: - 3000:3000 restart: unless-stopped diff --git a/prod.Dockerfile b/prod.Dockerfile index f7c8a058..641f932b 100644 --- a/prod.Dockerfile +++ b/prod.Dockerfile @@ -32,8 +32,8 @@ COPY . . # Environment variables must be present at build time # https://github.com/vercel/next.js/discussions/14030 -ARG NEXTAUTH_SECRET=$(openssl rand -base64 32) -ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET +ARG NEXTAUTH_SECRET +ENV NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-"$(openssl rand -base64 32)"} ARG DATABASE_URL @@ -55,29 +55,28 @@ ENV SERP_API_KEY=$SERP_API_KEY ARG NEXT_PUBLIC_GUEST_KEY ENV NEXT_PUBLIC_GUEST_KEY=$NEXT_PUBLIC_GUEST_KEY -# ARG NEXT_PUBLIC_FF_AUTH_ENABLED -# ENV NEXT_PUBLIC_FF_AUTH_ENABLED=$NEXT_PUBLIC_FF_AUTH_ENABLED +ARG NEXT_PUBLIC_FF_AUTH_ENABLED +ENV NEXT_PUBLIC_FF_AUTH_ENABLED=$NEXT_PUBLIC_FF_AUTH_ENABLED -# ARG GOOGLE_CLIENT_ID -# ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID +ARG GOOGLE_CLIENT_ID +ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID -# ARG GOOGLE_CLIENT_SECRET -# ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET +ARG GOOGLE_CLIENT_SECRET +ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET -# ARG GITHUB_CLIENT_ID -# ENV GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID +ARG GITHUB_CLIENT_ID +ENV GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID -# ARG GITHUB_CLIENT_SECRET -# ENV GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET +ARG GITHUB_CLIENT_SECRET +ENV GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET -# ARG DISCORD_CLIENT_ID -# ENV DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID +ARG DISCORD_CLIENT_ID +ENV DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID # Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry # Uncomment the following line to disable telemetry at build time # ENV NEXT_TELEMETRY_DISABLED 1 -ENTRYPOINT ["sh", "entrypoint.sh"] # Build Next.js based on the preferred package manager RUN \ @@ -100,17 +99,21 @@ RUN adduser --system --uid 1001 nextjs USER nextjs COPY --from=builder /app/public ./public +COPY --from=builder /app/entrypoint.sh ./ +COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma + + # 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/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static - # Environment variables must be redefined at run time -ARG NEXTAUTH_SECRET=$(openssl rand -base64 32) -ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET +ARG NEXTAUTH_SECRET +ENV NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-"$(openssl rand -base64 32)"} + ARG DATABASE_URL @@ -133,27 +136,29 @@ ENV SERP_API_KEY=$SERP_API_KEY ARG NEXT_PUBLIC_GUEST_KEY ENV NEXT_PUBLIC_GUEST_KEY=$NEXT_PUBLIC_GUEST_KEY -# ARG NEXT_PUBLIC_FF_AUTH_ENABLED -# ENV NEXT_PUBLIC_FF_AUTH_ENABLED=$NEXT_PUBLIC_FF_AUTH_ENABLED +ARG NEXT_PUBLIC_FF_AUTH_ENABLED +ENV NEXT_PUBLIC_FF_AUTH_ENABLED=$NEXT_PUBLIC_FF_AUTH_ENABLED -# ARG GOOGLE_CLIENT_ID -# ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID +ARG GOOGLE_CLIENT_ID +ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID -# ARG GOOGLE_CLIENT_SECRET -# ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET +ARG GOOGLE_CLIENT_SECRET +ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET -# ARG GITHUB_CLIENT_ID -# ENV GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID +ARG GITHUB_CLIENT_ID +ENV GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID -# ARG GITHUB_CLIENT_SECRET -# ENV GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET +ARG GITHUB_CLIENT_SECRET +ENV GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET -# ARG DISCORD_CLIENT_ID -# ENV DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID +ARG DISCORD_CLIENT_ID +ENV DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID # Uncomment the following line to disable telemetry at run time # ENV NEXT_TELEMETRY_DISABLED 1 # Note: Don't expose ports here, Compose will handle that for us +ENTRYPOINT ["sh", "entrypoint.sh"] + CMD ["node", "server.js"] diff --git a/src/env/schema.mjs b/src/env/schema.mjs index 6169c301..5f239295 100644 --- a/src/env/schema.mjs +++ b/src/env/schema.mjs @@ -9,7 +9,7 @@ const isProdutionAndAuthEnabled = const requiredAuthEnabledForProduction = () => { return isProdutionAndAuthEnabled ? z.string().min(1).trim() - : z.string().min(1).trim().optional(); + : z.string().optional(); }; const stringToBoolean = () => {