Skip to content

Commit

Permalink
fix: docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogtiti committed May 18, 2023
1 parent 9baacb5 commit 4e1101a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 60 deletions.
20 changes: 16 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=***
14 changes: 7 additions & 7 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
36 changes: 18 additions & 18 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
65 changes: 35 additions & 30 deletions prod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion src/env/schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down

0 comments on commit 4e1101a

Please sign in to comment.