fix: local docker image build (#4758)

Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
Anshuman Pandey
2025-02-28 16:23:23 +05:30
committed by GitHub
parent e3084760b8
commit fa7d33351f
12 changed files with 150 additions and 93 deletions

View File

@@ -1,39 +1,56 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
# **/node_modules
**/node_modules
.pnp
.pnp.js
.pnpm-store/
# testing
coverage
**/coverage
# next.js
**/.next
**/out
**/.next/
**/out/
**/build
# node
**/dist
**/dist/
# misc
.DS_Store
**/.DS_Store
*.pem
Zone.Identifier
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# turbo
.turbo
# local env files
**/.env
**/.env.local
**/.env.development.local
**/.env.test.local
**/.env.production.local
!packages/database/.env
!apps/web/.env
# nixos stuff
# build tools
.turbo
**/*vite.config.*.timestamp-*
# environment specific
.direnv
.vscode
.github
**/.turbo
# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
.env
# project specific
packages/lib/uploads
apps/web/public/js
packages/database/migrations
branch.json

43
.gitignore vendored
View File

@@ -1,25 +1,26 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
node_modules
**/node_modules
.pnp
.pnp.js
.pnpm-store/
# testing
coverage
**/coverage
# next.js
.next/
out/
build
**/.next/
**/out/
**/build
# node
dist/
**/dist/
# misc
.DS_Store
**/.DS_Store
*.pem
Zone.Identifier
# debug
npm-debug.log*
@@ -27,39 +28,29 @@ yarn-debug.log*
yarn-error.log*
# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
**/.env
**/.env.local
**/.env.development.local
**/.env.test.local
**/.env.production.local
!packages/database/.env
!apps/web/.env
# turbo
# build tools
.turbo
**/*vite.config.*.timestamp-*
# nixos stuff
# environment specific
.direnv
Zone.Identifier
# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
# uploads
# project specific
packages/lib/uploads
# Vite Timestamps
*vite.config.*.timestamp-*
# js compiled assets
apps/web/public/js
packages/database/migrations
# tolgee
branch.json

View File

@@ -33,6 +33,9 @@ ENV CRON_SECRET="placeholder_for_cron_secret_of_64_chars_get_overwritten_at_runt
ARG NEXT_PUBLIC_SENTRY_DSN
ARG SENTRY_AUTH_TOKEN
# Increase Node.js memory limit
# ENV NODE_OPTIONS="--max_old_space_size=4096"
# Set the working directory
WORKDIR /app
@@ -41,19 +44,17 @@ WORKDIR /app
# COPY --from=builder /app/out/json/ .
# COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
# Install the dependencies
# RUN pnpm install
# Prepare the build
COPY . .
# Create a .env file
RUN touch apps/web/.env
# Install the dependencies
RUN pnpm install
# Build the project
# RUN pnpm post-install --filter=@formbricks/web...
RUN pnpm build --filter=@formbricks/web...
RUN NODE_OPTIONS="--max_old_space_size=4096" pnpm build --filter=@formbricks/web...
# Extract Prisma version
RUN jq -r '.devDependencies.prisma' packages/database/package.json > /prisma_version.txt
@@ -76,6 +77,7 @@ WORKDIR /home/nextjs
COPY --from=installer /app/apps/web/next.config.mjs .
COPY --from=installer /app/apps/web/package.json .
# Leverage output traces to reduce image size
COPY --from=installer --chown=nextjs:nextjs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nextjs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nextjs /app/apps/web/public ./apps/web/public

View File

@@ -33,8 +33,8 @@
"@paralleldrive/cuid2": "2.2.2",
"prisma": "6.0.1",
"prisma-dbml-generator": "0.12.0",
"prisma-json-types-generator": "3.1.1",
"ts-node": "10.9.2",
"zod": "3.24.1"
"zod": "3.24.1",
"prisma-json-types-generator": "3.2.2"
}
}

View File

@@ -28,7 +28,11 @@ const config = () => {
rollupTypes: true,
bundledPackages: ["@formbricks/api", "@formbricks/types"],
}),
copyCompiledAssetsPlugin({ filename: "formbricks", distDir: resolve(__dirname, "dist") }),
copyCompiledAssetsPlugin({
filename: "formbricks",
distDir: resolve(__dirname, "dist"),
skipDirectoryCheck: true, // Skip checking for subdirectories that might not exist
}),
],
});
};

View File

@@ -6,6 +6,7 @@
"continue_with_google": "Login mit Google",
"continue_with_oidc": "Weiter mit {oidcDisplayName}",
"continue_with_openid": "Login mit OpenID",
"continue_with_saml": "Login mit SAML SSO",
"forgot-password": {
"back_to_login": "Zurück zum Login",
"email-sent": {
@@ -52,6 +53,7 @@
"new_to_formbricks": "Neu bei Formbricks?",
"use_a_backup_code": "Einen Backup-Code verwenden"
},
"saml_connection_error": "Etwas ist schiefgelaufen. Bitte überprüfe die App-Konsole für weitere Details.",
"signup": {
"captcha_failed": "reCAPTCHA fehlgeschlagen",
"have_an_account": "Hast Du ein Konto?",

View File

@@ -6,6 +6,7 @@
"continue_with_google": "Continue with Google",
"continue_with_oidc": "Continue with {oidcDisplayName}",
"continue_with_openid": "Continue with OpenID",
"continue_with_saml": "Continue with SAML SSO",
"forgot-password": {
"back_to_login": "Back to login",
"email-sent": {
@@ -52,6 +53,7 @@
"new_to_formbricks": "New to Formbricks?",
"use_a_backup_code": "Use a backup code"
},
"saml_connection_error": "Something went wrong. Please check your app console for more details.",
"signup": {
"captcha_failed": "Captcha failed",
"have_an_account": "Have an account?",

View File

@@ -6,6 +6,7 @@
"continue_with_google": "Continuer avec Google",
"continue_with_oidc": "Continuer avec {oidcDisplayName}",
"continue_with_openid": "Continuer avec OpenID",
"continue_with_saml": "Continuer avec SAML SSO",
"forgot-password": {
"back_to_login": "Retour à la connexion",
"email-sent": {
@@ -52,6 +53,7 @@
"new_to_formbricks": "Nouveau sur Formbricks ?",
"use_a_backup_code": "Utiliser un code de secours"
},
"saml_connection_error": "Quelque chose s'est mal passé. Veuillez vérifier la console de votre application pour plus de détails.",
"signup": {
"captcha_failed": "Captcha échoué",
"have_an_account": "Avez-vous un compte ?",

View File

@@ -6,6 +6,7 @@
"continue_with_google": "Continuar com o Google",
"continue_with_oidc": "Continuar com {oidcDisplayName}",
"continue_with_openid": "Continuar com OpenID",
"continue_with_saml": "Continuar com SAML SSO",
"forgot-password": {
"back_to_login": "Voltar para o login",
"email-sent": {
@@ -52,6 +53,7 @@
"new_to_formbricks": "Novo no Formbricks?",
"use_a_backup_code": "Usar um código de backup"
},
"saml_connection_error": "Algo deu errado. Por favor, verifica o console do app para mais detalhes.",
"signup": {
"captcha_failed": "reCAPTCHA falhou",
"have_an_account": "Já tem uma conta?",

View File

@@ -6,6 +6,7 @@
"continue_with_google": "使用 Google 繼續",
"continue_with_oidc": "使用 '{'oidcDisplayName'}' 繼續",
"continue_with_openid": "使用 OpenID 繼續",
"continue_with_saml": "使用 SAML SSO 繼續",
"forgot-password": {
"back_to_login": "返回登入",
"email-sent": {
@@ -52,6 +53,7 @@
"new_to_formbricks": "初次使用 Formbricks",
"use_a_backup_code": "使用備份碼"
},
"saml_connection_error": "發生錯誤。請檢查您的 app 主控台以取得更多詳細資料。",
"signup": {
"captcha_failed": "驗證碼失敗",
"have_an_account": "已有帳戶?",

View File

@@ -6,6 +6,7 @@ import { type Plugin, type ResolvedConfig } from "vite";
interface CopyCompiledAssetsPluginOptions {
filename: string;
distDir: string;
skipDirectoryCheck?: boolean; // New option to skip checking non-existent directories
}
const ensureDirectoryExists = async (dirPath: string): Promise<void> => {
@@ -32,30 +33,67 @@ export function copyCompiledAssetsPlugin(options: CopyCompiledAssetsPluginOption
},
async writeBundle() {
const outputDir = path.resolve(config.root, "../../apps/web/public/js");
const distDir = path.resolve(config.root, options.distDir);
try {
const outputDir = path.resolve(config.root, "../../apps/web/public/js");
const distDir = path.resolve(config.root, options.distDir);
// Create the output directory if it doesn't exist
// fs.ensureDirSync(outputDir);
await ensureDirectoryExists(outputDir);
console.log(`Ensured directory exists: ${outputDir}`);
// Create the output directory if it doesn't exist
await ensureDirectoryExists(outputDir);
console.log(`Ensured directory exists: ${outputDir}`);
// Copy files from distDir to outputDir
const filesToCopy = await readdir(distDir);
for (const file of filesToCopy) {
const srcFile = path.resolve(distDir, file);
const destFile = path.resolve(outputDir, file.replace("index", options.filename));
// Check if the srcFile is a regular file before copying
const fileStat = await stat(srcFile);
if (!fileStat.isFile()) {
continue; // Skip directories, or other non-regular files
// Check if the dist directory exists
try {
await access(distDir);
} catch (error) {
if ((error as { code: string }).code === "ENOENT") {
console.error(`Error: Distribution directory ${distDir} does not exist`);
if (!options.skipDirectoryCheck) {
throw error;
} else {
console.log(`Skipping directory check as skipDirectoryCheck is enabled`);
return; // Skip further processing
}
} else {
throw error;
}
}
await copyFile(srcFile, destFile);
}
// Copy files from distDir to outputDir
const filesToCopy = await readdir(distDir);
let copiedFiles = 0;
console.log(`Copied ${filesToCopy.length.toString()} files to ${outputDir} (${options.filename})`);
for (const file of filesToCopy) {
const srcFile = path.resolve(distDir, file);
const destFile = path.resolve(outputDir, file.replace("index", options.filename));
try {
// Check if the srcFile is a regular file before copying
const fileStat = await stat(srcFile);
if (!fileStat.isFile()) {
continue; // Skip directories, or other non-regular files
}
await copyFile(srcFile, destFile);
copiedFiles++;
} catch (error) {
if ((error as { code: string }).code === "ENOENT" && options.skipDirectoryCheck) {
console.log(`Skipping non-existent file: ${srcFile}`);
continue;
}
throw error;
}
}
console.log(`Copied ${String(copiedFiles)} files to ${outputDir} (${options.filename})`);
} catch (error) {
if (options.skipDirectoryCheck) {
console.error(
`Warning: Error during copy operation, but continuing due to skipDirectoryCheck: ${String(error)}`
);
} else {
throw error;
}
}
},
};
}

49
pnpm-lock.yaml generated
View File

@@ -678,8 +678,8 @@ importers:
specifier: 0.12.0
version: 0.12.0(encoding@0.1.13)
prisma-json-types-generator:
specifier: 3.1.1
version: 3.1.1(prisma@6.0.1)(typescript@5.7.2)
specifier: 3.2.2
version: 3.2.2(prisma@6.0.1)(typescript@5.7.2)
ts-node:
specifier: 10.9.2
version: 10.9.2(@types/node@22.10.2)(typescript@5.7.2)
@@ -3654,8 +3654,8 @@ packages:
'@prisma/debug@5.0.0':
resolution: {integrity: sha512-3q/M/KqlQ01/HJXifU/zCNOHkoTWu24kGelMF/IBrRxm7njPqTTbwfnT1dh4JK+nuWM5/Dg1Lv00u2c0l7AHxg==}
'@prisma/debug@5.20.0':
resolution: {integrity: sha512-oCx79MJ4HSujokA8S1g0xgZUGybD4SyIOydoHMngFYiwEwYDQ5tBQkK5XoEHuwOYDKUOKRn/J0MEymckc4IgsQ==}
'@prisma/debug@6.0.0':
resolution: {integrity: sha512-eUjoNThlDXdyJ1iQ2d7U6aTVwm59EwvODb5zFVNJEokNoSiQmiYWNzZIwZyDmZ+j51j42/0iTaHIJ4/aZPKFRg==}
'@prisma/debug@6.0.1':
resolution: {integrity: sha512-jQylgSOf7ibTVxqBacnAlVGvek6fQxJIYCQOeX2KexsfypNzXjJQSS2o5s+Mjj2Np93iSOQUaw6TvPj8syhG4w==}
@@ -3684,8 +3684,8 @@ packages:
'@prisma/generator-helper@5.0.0':
resolution: {integrity: sha512-pufQ1mhoH6WzKNtzL79HZDoW4Ql3Lf8QEKVmBoW8e3Tdb50bxpYBYue5LBqp9vNW1xd1pgZO53cNiRfLX2d4Zg==}
'@prisma/generator-helper@5.20.0':
resolution: {integrity: sha512-37Aibw0wVRQgQVtCdNAIN71YFnSQfvetok7vd95KKkYkQRbEx94gsvPDpyN9Mw7p3IwA3nFgPfLc3jBRztUkKw==}
'@prisma/generator-helper@6.0.0':
resolution: {integrity: sha512-5DkG7hspZo6U4OtqI2W0JcgtY37sr7HgT8Q0W/sjL4VoV4px6ivzK6Eif5bKM7q+S4yFUHtjUt/3s69ErfLn7A==}
'@prisma/get-platform@5.0.0':
resolution: {integrity: sha512-JT/rz/jaMTggDkd9OIma50si9rPLzSFe7XSrV3mKXwtv9t+rdwx5ZhmKJd+Rz6S1vhn/291k21JLfaxOW6u8KQ==}
@@ -10730,12 +10730,12 @@ packages:
resolution: {integrity: sha512-b5CqA9cCY5jmNJGjx8oUbPw3KSgVd+mu8711MSZIRY9dIF0Vlcs/Au6LR3S5guncydM7Zkh8iz8vC+c2CDj3Xw==}
hasBin: true
prisma-json-types-generator@3.1.1:
resolution: {integrity: sha512-LYVBKWcnh6SSPf6jNJuQEmByyZtj79kuxzilCF8962ViBNciBzk+pQ8qt7HR7lFUIOEN3sUeOOhJe1RuytGk6A==}
prisma-json-types-generator@3.2.2:
resolution: {integrity: sha512-kvEbJPIP5gxk65KmLs0nAvY+CxpqVMWb4OsEvXlyXZmp2IGfi5f52BUV7ezTYQNjRPZyR4QlayWJXffoqVVAfA==}
engines: {node: '>=14.0'}
hasBin: true
peerDependencies:
prisma: ^5.20
prisma: ^5 || ^6
typescript: ^5.6.2
prisma@6.0.1:
@@ -12134,9 +12134,6 @@ packages:
tslib@1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
tslib@2.7.0:
resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==}
tslib@2.8.1:
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
@@ -16448,7 +16445,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@prisma/debug@5.20.0': {}
'@prisma/debug@6.0.0': {}
'@prisma/debug@6.0.1': {}
@@ -16505,9 +16502,9 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@prisma/generator-helper@5.20.0':
'@prisma/generator-helper@6.0.0':
dependencies:
'@prisma/debug': 5.20.0
'@prisma/debug': 6.0.0
'@prisma/get-platform@5.0.0':
dependencies:
@@ -17419,7 +17416,7 @@ snapshots:
'@babel/plugin-transform-sticky-regex': 7.25.9(@babel/core@7.26.0)
'@babel/plugin-transform-typescript': 7.26.7(@babel/core@7.26.0)
'@babel/plugin-transform-unicode-regex': 7.25.9(@babel/core@7.26.0)
'@babel/template': 7.25.9
'@babel/template': 7.26.9
'@react-native/babel-plugin-codegen': 0.74.87(@babel/preset-env@7.26.7(@babel/core@7.26.0))
babel-plugin-transform-flow-enums: 0.0.2(@babel/core@7.26.0)
react-refresh: 0.14.2
@@ -19496,7 +19493,7 @@ snapshots:
'@vue/compiler-core@3.5.13':
dependencies:
'@babel/parser': 7.26.7
'@babel/parser': 7.26.9
'@vue/shared': 3.5.13
entities: 4.5.0
estree-walker: 2.0.2
@@ -23894,8 +23891,8 @@ snapshots:
metro-transform-plugins@0.80.12:
dependencies:
'@babel/core': 7.26.0
'@babel/generator': 7.26.5
'@babel/template': 7.25.9
'@babel/generator': 7.26.9
'@babel/template': 7.26.9
'@babel/traverse': 7.26.7
flow-enums-runtime: 0.0.6
nullthrows: 1.1.1
@@ -23916,9 +23913,9 @@ snapshots:
metro-transform-worker@0.80.12:
dependencies:
'@babel/core': 7.26.0
'@babel/generator': 7.26.5
'@babel/parser': 7.26.7
'@babel/types': 7.26.7
'@babel/generator': 7.26.9
'@babel/parser': 7.26.9
'@babel/types': 7.26.9
flow-enums-runtime: 0.0.6
metro: 0.80.12
metro-babel-transformer: 0.80.12
@@ -25141,11 +25138,11 @@ snapshots:
- encoding
- supports-color
prisma-json-types-generator@3.1.1(prisma@6.0.1)(typescript@5.7.2):
prisma-json-types-generator@3.2.2(prisma@6.0.1)(typescript@5.7.2):
dependencies:
'@prisma/generator-helper': 5.20.0
'@prisma/generator-helper': 6.0.0
prisma: 6.0.1
tslib: 2.7.0
tslib: 2.8.1
typescript: 5.7.2
prisma@6.0.1:
@@ -26843,8 +26840,6 @@ snapshots:
tslib@1.14.1: {}
tslib@2.7.0: {}
tslib@2.8.1: {}
tsup@8.3.5(@microsoft/api-extractor@7.49.1(@types/node@22.10.2))(jiti@2.4.1)(postcss@8.5.2)(tsx@4.19.2)(typescript@5.7.2)(yaml@2.7.0):