From f5110fe9c1061ba69cccb5ec90f3693335e5b992 Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Thu, 7 Dec 2023 23:24:22 +0100 Subject: [PATCH] fix: docker build errors (#1762) --- .github/workflows/release-docker-github.yml | 16 ++++++++++------ apps/web/Dockerfile | 12 ++++++++++++ apps/web/next.config.mjs | 8 ++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release-docker-github.yml b/.github/workflows/release-docker-github.yml index 3911c352da..0dddc0fd41 100644 --- a/.github/workflows/release-docker-github.yml +++ b/.github/workflows/release-docker-github.yml @@ -52,19 +52,22 @@ jobs: with: cosign-release: "v2.1.1" + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx - uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 - with: - platforms: linux/amd64,linux/arm64 + uses: docker/setup-buildx-action@v3 # v3.0.0 # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + uses: docker/login-action@v3 # v3.0.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -74,7 +77,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + uses: docker/metadata-action@v5 # v5.0.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} @@ -82,10 +85,11 @@ jobs: # https://github.com/docker/build-push-action - name: Build and push Docker image id: build-and-push - uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + uses: docker/build-push-action@v5 # v5.0.0 with: context: . file: ./apps/web/Dockerfile + # platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 9fc7682f2d..11d19d3510 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -1,13 +1,19 @@ # Installer stage: Building the application FROM node:20-alpine AS installer + +# Enable corepack and prepare pnpm RUN corepack enable && corepack prepare pnpm@latest --activate +# Install necessary build tools and compilers +RUN apk update && apk add --no-cache g++ cmake make gcc python3 openssl-dev + # Install Supercronic (cron for containers without super user privileges) RUN apk add --no-cache curl \ && curl -fsSLo /tmp/supercronic \ "https://github.com/aptible/supercronic/releases/download/v0.2.27/supercronic-linux-amd64" \ && chmod +x /tmp/supercronic +# Set environment variables ARG DATABASE_URL ENV DATABASE_URL=$DATABASE_URL @@ -17,13 +23,19 @@ ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET ARG ENCRYPTION_KEY ENV ENCRYPTION_KEY=$ENCRYPTION_KEY +# Set the working directory WORKDIR /app +# Copy the application files COPY . . + +# Create a .env file RUN touch /app/apps/web/.env +# Install the dependencies RUN pnpm install + # Build the project RUN pnpm post-install --filter=web... RUN pnpm turbo run build --filter=web... diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 3cdeaffbf7..a18b9ca787 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -38,10 +38,6 @@ const nextConfig = { protocol: "https", hostname: "formbricks-cdn.s3.eu-central-1.amazonaws.com", }, - { - protocol: "https", - hostname: `${getHostname(process.env.WEBAPP_URL)}`, - }, ], }, async redirects() { @@ -116,6 +112,10 @@ if (process.env.WEBAPP_URL) { nextConfig.experimental.serverActions = { allowedOrigins: [process.env.WEBAPP_URL.replace(/https?:\/\//, "")], }; + nextConfig.images.remotePatterns.push({ + protocol: "https", + hostname: getHostname(process.env.WEBAPP_URL), + }); } const sentryOptions = {