Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 295/docker images dont work #312

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ADD client/package.json client/package-lock.json ./
RUN npm install

ADD client /app/
RUN cp .env.docker .env
RUN npm run build

# syntax=docker/dockerfile:1.3-labs
Expand Down
1 change: 1 addition & 0 deletions client/.env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ NUXT_PUBLIC_H_CAPTCHA_SITE_KEY=
NUXT_PUBLIC_PAID_PLANS_ENABLED=
NUXT_PUBLIC_S3_ENABLED=
NUXT_API_SECRET=
NUXT_PUBLIC_USE_NULL_IMAGE_PROVIDER=yes
22 changes: 22 additions & 0 deletions client/lib/null-image-provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { joinURL } from 'ufo'
import { createOperationsGenerator } from '#image'

const operationsGenerator = createOperationsGenerator()

export const getImage = (
src,
{ modifiers = {}, baseURL } = {}
) => {

if (!baseURL) {
// also support runtime config
baseURL = useRuntimeConfig().public.siteUrl
}

const operations = operationsGenerator(modifiers)

return {
url: joinURL(baseURL, src + (operations ? '?' + operations : '')),
}
}

15 changes: 12 additions & 3 deletions client/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,18 @@ export default defineNuxtConfig({
}
}
},
image: {
quality: 95,
},
image: (
runtimeConfig.public.useNullImageProvider ? {
provider: 'null',
providers: {
null: {
provider: '~/lib/null-image-provider.js',
}
}
} : {
quality: 95,
}
),
sourcemap: true,
vite: {
plugins: [
Expand Down
5 changes: 4 additions & 1 deletion client/runtimeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export default {
s3Enabled: process.env.NUXT_PUBLIC_S3_ENABLED || false,
paidPlansEnabled: process.env.NUXT_PUBLIC_PAID_PLANS_ENABLED || false,
customDomainsEnabled: process.env.NUXT_PUBLIC_CUSTOM_DOMAINS_ENABLED || false,

useNullImageProvider: (
process.env.NUXT_PUBLIC_USE_NULL_IMAGE_PROVIDER == 'yes'
),

// Config within public will be also exposed to the client
SENTRY_DSN_PUBLIC: process.env.SENTRY_DSN_PUBLIC,
SENTRY_TRACES_SAMPLE_RATE: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE ?? '0'),
Expand Down
5 changes: 2 additions & 3 deletions docker/nuxt-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ nvm use 20
cd /app/nuxt/server/

. /app/client/.env
[ "x$NUXT_API_SECRET" != "x" ] || generate-api-secret.sh

sed 's/^/export /' < /app/.nuxt.env > env.sh
[ "x$NUXT_API_SECRET" != "x" ] || generate-api-secret.sh

. env.sh
eval $(sed 's/^/export /' < /app/client/.env)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using eval to export environment variables from the .env file poses a security risk if the .env file contains untrusted input. Consider using a safer method to parse and export environment variables.


node index.mjs
Loading