diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 95910343..2700163b 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -38,20 +38,18 @@ jobs: context: . file: prod.Dockerfile build-args: | - SKIP_ENV_VALIDATION=1 - NEXTAUTH_SECRET: ${NEXTAUTH_SECRET} - NEXTAUTH_URL: ${NEXTAUTH_URL} - DATABASE_URL: ${DATABASE_URL} + NEXTAUTH_URL=http://localhost:3000 + DATABASE_URL=file:./db.sqlite 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/dev.Dockerfile b/dev.Dockerfile index f7965199..2f169650 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -2,6 +2,8 @@ FROM node:19-alpine RUN apk update && apk add --no-cache openssl +ARG NEXTAUTH_SECRET=$(openssl rand -base64 32) +ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET ARG DATABASE_URL ENV DATABASE_URL=$DATABASE_URL @@ -28,6 +30,9 @@ COPY . . # Prevent Husky errors by disabling the `prepare` script RUN npm pkg set scripts.prepare="exit 0" +# set npm registry +RUN npm config set registry 'https://registry.npmmirror.com/' + RUN \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ elif [ -f package-lock.json ]; then npm ci; \ diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 1a144f1c..d79829e9 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -11,9 +11,8 @@ services: context: . dockerfile: dev.Dockerfile args: - NEXTAUTH_SECRET: ${NEXTAUTH_SECRET} - NEXTAUTH_URL: ${NEXTAUTH_URL} - DATABASE_URL: ${DATABASE_URL} + NEXTAUTH_URL: http://localhost:3000 + DATABASE_URL: file:./db.sqlite SKIP_ENV_VALIDATION: 1 # omit this property to enable schema validation for the environment variables container_name: autogpt environment: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 464fcfdb..71b5c6fb 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -3,21 +3,24 @@ version: '3' services: autogpt: container_name: autogpt - image: dogtititi/autogpt-next-web:latest - args: - NEXTAUTH_SECRET: ${NEXTAUTH_SECRET} - NEXTAUTH_URL: ${NEXTAUTH_URL} - DATABASE_URL: ${DATABASE_URL} - 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_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 + # 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 ports: - 3000:3000 restart: unless-stopped diff --git a/prod.Dockerfile b/prod.Dockerfile index e34b8623..f7c8a058 100644 --- a/prod.Dockerfile +++ b/prod.Dockerfile @@ -3,6 +3,8 @@ FROM node:19-alpine AS base # Step 1. Rebuild the source code only when needed FROM base AS builder +RUN apk update && apk add --no-cache openssl + WORKDIR /app # Install dependencies based on the preferred package manager @@ -12,6 +14,9 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ # Prevent Husky errors by disabling the `prepare` script RUN npm pkg set scripts.prepare="exit 0" +# set npm registry +RUN npm config set registry 'https://registry.npmmirror.com/' + # Omit --production flag for TypeScript devDependencies RUN \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ @@ -27,14 +32,13 @@ COPY . . # Environment variables must be present at build time # https://github.com/vercel/next.js/discussions/14030 -ARG SKIP_ENV_VALIDATION -ENV SKIP_ENV_VALIDATION=$SKIP_ENV_VALIDATION +ARG NEXTAUTH_SECRET=$(openssl rand -base64 32) +ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET + ARG DATABASE_URL ENV DATABASE_URL=$DATABASE_URL -ARG NEXTAUTH_SECRET -ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET ARG NEXTAUTH_URL ENV NEXTAUTH_URL=$NEXTAUTH_URL @@ -51,28 +55,30 @@ 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 \ if [ -f yarn.lock ]; then yarn build; \ @@ -102,14 +108,14 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static # Environment variables must be redefined at run time -ARG SKIP_ENV_VALIDATION -ENV SKIP_ENV_VALIDATION=$SKIP_ENV_VALIDATION + +ARG NEXTAUTH_SECRET=$(openssl rand -base64 32) +ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET + ARG DATABASE_URL ENV DATABASE_URL=$DATABASE_URL -ARG NEXTAUTH_SECRET -ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET ARG NEXTAUTH_URL ENV NEXTAUTH_URL=$NEXTAUTH_URL @@ -127,23 +133,23 @@ 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