This commit is contained in:
Naitik
2023-10-05 16:42:38 +05:30
12 changed files with 208 additions and 164 deletions
@@ -61,10 +61,12 @@ Ensure `docker` & `docker compose` are installed on your server/system. Both are
You're now ready to start the Formbricks Docker setup. The following command will start Formbricks together with a postgreSQL database using Docker Compose:
We pass the `--env-file /dev/null` flag to docker-compose to prevent it from reading the .env file. This is because we're using environment variables directly in the docker-compose.yml file as the env file is currently in a format not well recognised by docker systems.
<CodeGroup title="Launch Docker Instance">
```bash
docker compose up -d
docker compose --env-file /dev/null up -d
```
</CodeGroup>
@@ -103,7 +105,7 @@ Ensure `docker` & `docker compose` are installed on your server/system. Both are
<CodeGroup title="Relaunch the Docker Instance">
```bash
docker compose up -d
docker compose --env-file /dev/null up -d
```
</CodeGroup>
@@ -29,7 +29,7 @@ Ensure `docker` & `docker compose` are installed on your server/system. Both are
</CodeGroup>
2. **Modify the `.env.docker` file as required by your setup.** <br/> This file comes with a basic setup and Formbricks works without making any changes to the file. To enable email sending functionality you need to configure the SMTP settings. If you configured your email credentials, you can also comment the following lines to enable email verification (`# EMAIL_VERIFICATION_DISABLED=1`) and password reset (`# PASSWORD_RESET_DISABLED=1`)
2. **Modify the environment variables in your `docker-compose.yml` file as required by your setup.** <br/> This file comes with a basic setup and Formbricks works without making any changes to the file. To enable email sending functionality you need to configure the SMTP settings. If you configured your email credentials, you can also comment the following lines to enable email verification (`# NEXT_PUBLIC_EMAIL_VERIFICATION_DISABLED=1`) and password reset (`# NEXT_PUBLIC_PASSWORD_RESET_DISABLED=1`)
<Note>
## Editing a NEXT_PUBLIC_* variable?
@@ -38,12 +38,26 @@ Ensure `docker` & `docker compose` are installed on your server/system. Both are
to take effect.
</Note>
3. **Start the docker compose process.** <br/> Finally start the docker compose process to build and spin up the Formbricks container as well as the PostgreSQL database. <br/> _Use docker-compose if you are on an older docker version_
3. **Generate NextAuth Secret**
Next, you need to generate a NextAuth secret. This will be used for session signing and encryption. The `sed` command below generates a random string using `openssl`, then replaces the `NEXTAUTH_SECRET:` placeholder in the `docker-compose.yml` file with this generated secret:
<CodeGroup title="Generate NextAuth Secret">
```bash
sed -i "/x-nextauth-secret: &nextauth_secret/s/RANDOM_STRING/$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)/" docker-compose.yml
```
</CodeGroup>
4. **Start the docker compose process.** <br/> Finally start the docker compose process to build and spin up the Formbricks container as well as the PostgreSQL database. <br/> _Use docker-compose if you are on an older docker version_
We pass the `--env-file /dev/null` flag to docker-compose to prevent it from reading the .env file. This is because we're using environment variables directly in the docker-compose.yml file as the env file is currently in a format not well recognised by docker systems.
<CodeGroup title="Launch docker instances">
```bash
docker compose up -d
docker compose --env-file /dev/null up
```
</CodeGroup>
@@ -59,7 +73,6 @@ These variables must also be provided at runtime.
| WEBAPP_URL | Base URL of the site. | required | `http://localhost:3000` |
| SURVEY_BASE_URL | Base URL of the link surveys. | required | `http://localhost:3000/s/` |
| DATABASE_URL | Database URL with credentials. | required | `postgresql://postgres:postgres@postgres:5432/formbricks?schema=public` |
| PRISMA_GENERATE_DATAPROXY | Enables a dedicated connection pool for Prisma using Prisma Data Proxy. Uncomment to enable. | optional | |
| NEXTAUTH_SECRET | Secret for NextAuth, used for session signing and encryption. | required | (Generated by the user) |
| NEXTAUTH_URL | Location of the auth server. By default, this is the Formbricks docker instance itself. | required | `http://localhost:3000` |
| PRIVACY_URL | URL for privacy policy. | optional | |
@@ -75,12 +75,6 @@ x-environment: &environment
# PostgreSQL DB for Formbricks to connect to
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/formbricks?schema=public"
# Uncomment to enable a dedicated connection pool for Prisma using Prisma Data Proxy
# Cold boots will be faster and you'll be able to scale your DB independently of your app.
# @see https://www.prisma.io/docs/data-platform/data-proxy/use-data-proxy
# PRISMA_GENERATE_DATAPROXY=true
PRISMA_GENERATE_DATAPROXY:
# NextJS Auth
# @see: https://next-auth.js.org/configuration/options#nextauth_secret
# You can use: `openssl rand -base64 32` to generate one
+11 -5
View File
@@ -1,11 +1,17 @@
FROM node:18-alpine AS installer
RUN corepack enable && corepack prepare pnpm@latest --activate
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
ARG NEXTAUTH_SECRET
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
WORKDIR /app
COPY . .
# Copy .env file because Docker don't follow symlinks
COPY .env.docker /app/apps/web/.env
RUN touch /app/apps/web/.env
RUN pnpm install
@@ -34,13 +40,13 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/publ
COPY --from=installer --chown=nextjs:nodejs /app/packages/database/schema.prisma ./packages/database/schema.prisma
COPY --from=installer --chown=nextjs:nodejs /app/packages/database/migrations ./packages/database/migrations
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
EXPOSE 3000
ENV HOSTNAME "0.0.0.0"
CMD if [ "$NEXTAUTH_SECRET" != "RANDOM_STRING" ]; then \
pnpm dlx prisma migrate deploy && node apps/web/server.js; \
else \
echo "ERROR: Please set a value for NEXTAUTH_SECRET in .env.docker!"; \
echo "ERROR: Please set a value for NEXTAUTH_SECRET in your docker compose variables!"; \
exit 1; \
fi
-2
View File
@@ -9,7 +9,6 @@ export const env = createEnv({
server: {
WEBAPP_URL: z.string().url().optional(),
DATABASE_URL: z.string().url(),
PRISMA_GENERATE_DATAPROXY: z.enum(["true", ""]).optional(),
NEXTAUTH_SECRET: z.string().min(1),
NEXTAUTH_URL: z.string().url().optional(),
MAIL_FROM: z.string().email().optional(),
@@ -82,7 +81,6 @@ export const env = createEnv({
runtimeEnv: {
WEBAPP_URL: process.env.WEBAPP_URL,
DATABASE_URL: process.env.DATABASE_URL,
PRISMA_GENERATE_DATAPROXY: process.env.PRISMA_GENERATE_DATAPROXY,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
MAIL_FROM: process.env.MAIL_FROM,
+1 -3
View File
@@ -4,10 +4,8 @@ import { createId } from "@paralleldrive/cuid2";
/** @type {import('next').NextConfig} */
const isCloud = process.env.IS_FORMBRICKS_CLOUD === "1";
const nextConfig = {
assetPrefix: isCloud ? process.env.WEBAPP_URL : undefined,
assetPrefix: process.env.ASSET_PREFIX_URL || undefined,
output: "standalone",
experimental: {
serverActions: true,