mirror of
https://github.com/coollabsio/coolify-examples.git
synced 2026-02-19 05:48:58 +00:00
new examples
This commit is contained in:
36
node/nuxtjs/ssr/.coolpack/Dockerfile
Normal file
36
node/nuxtjs/ssr/.coolpack/Dockerfile
Normal file
@@ -0,0 +1,36 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Generated by Coolpack
|
||||
# Provider: node, Framework: nuxt, Output: server
|
||||
|
||||
FROM node:24-slim AS builder
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
|
||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN --mount=type=cache,target=/app/node_modules/.cache pnpm build
|
||||
|
||||
FROM node:24-slim AS runner
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
RUN addgroup --system --gid 1001 coolgroup && \
|
||||
adduser --system --uid 1001 --ingroup coolgroup cooluser
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/.output ./.output
|
||||
|
||||
RUN chown -R cooluser:coolgroup /app
|
||||
USER cooluser
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
11
node/nuxtjs/ssr/.dockerignore
Normal file
11
node/nuxtjs/ssr/.dockerignore
Normal file
@@ -0,0 +1,11 @@
|
||||
node_modules/
|
||||
.git/
|
||||
.gitignore
|
||||
.env
|
||||
.env.local
|
||||
*.md
|
||||
.DS_Store
|
||||
*.log
|
||||
npm-debug.log*
|
||||
.nuxt/
|
||||
.output/
|
||||
24
node/nuxtjs/ssr/.gitignore
vendored
Normal file
24
node/nuxtjs/ssr/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Nuxt dev/build outputs
|
||||
.output
|
||||
.data
|
||||
.nuxt
|
||||
.nitro
|
||||
.cache
|
||||
dist
|
||||
|
||||
# Node dependencies
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
75
node/nuxtjs/ssr/README.md
Normal file
75
node/nuxtjs/ssr/README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Nuxt Minimal Starter
|
||||
|
||||
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
|
||||
|
||||
## Setup
|
||||
|
||||
Make sure to install dependencies:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install
|
||||
|
||||
# pnpm
|
||||
pnpm install
|
||||
|
||||
# yarn
|
||||
yarn install
|
||||
|
||||
# bun
|
||||
bun install
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
Start the development server on `http://localhost:3000`:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run dev
|
||||
|
||||
# pnpm
|
||||
pnpm dev
|
||||
|
||||
# yarn
|
||||
yarn dev
|
||||
|
||||
# bun
|
||||
bun run dev
|
||||
```
|
||||
|
||||
## Production
|
||||
|
||||
Build the application for production:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run build
|
||||
|
||||
# pnpm
|
||||
pnpm build
|
||||
|
||||
# yarn
|
||||
yarn build
|
||||
|
||||
# bun
|
||||
bun run build
|
||||
```
|
||||
|
||||
Locally preview production build:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run preview
|
||||
|
||||
# pnpm
|
||||
pnpm preview
|
||||
|
||||
# yarn
|
||||
yarn preview
|
||||
|
||||
# bun
|
||||
bun run preview
|
||||
```
|
||||
|
||||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
||||
34
node/nuxtjs/ssr/app/app.vue
Normal file
34
node/nuxtjs/ssr/app/app.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
// Fetch private env vars from server API
|
||||
const { data: serverEnv } = await useFetch('/api/env');
|
||||
|
||||
// Build-time public var (accessible on client)
|
||||
const buildPublicVar = import.meta.env.BUILD_PUBLIC_VAR || 'default-value';
|
||||
|
||||
onMounted(() => {
|
||||
console.log('=== Build-time Variables ===');
|
||||
console.log('BUILD_PUBLIC_VAR:', buildPublicVar);
|
||||
console.log('=== Runtime Variables ===');
|
||||
console.log('NUXT_RUNTIME_PRIVATE_VAR:', serverEnv.value?.runtimePrivateVar);
|
||||
console.log('NUXT_PUBLIC_RUNTIME_PUBLIC_VAR:', config.public.runtimePublicVar);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<NuxtRouteAnnouncer />
|
||||
<div style="padding: 20px; background: #f0f0f0; margin: 20px; border-radius: 8px;">
|
||||
<h2>Environment Variable Test</h2>
|
||||
|
||||
<h3>Build-time (baked into bundle)</h3>
|
||||
<p><strong>BUILD_PUBLIC_VAR:</strong> {{ buildPublicVar }}</p>
|
||||
|
||||
<h3>Runtime (read at server startup)</h3>
|
||||
<p><strong>NUXT_RUNTIME_PRIVATE_VAR:</strong> {{ serverEnv?.runtimePrivateVar }}</p>
|
||||
<p><strong>NUXT_PUBLIC_RUNTIME_PUBLIC_VAR:</strong> {{ config.public.runtimePublicVar }}</p>
|
||||
</div>
|
||||
<NuxtWelcome />
|
||||
</div>
|
||||
</template>
|
||||
21
node/nuxtjs/ssr/nuxt.config.ts
Normal file
21
node/nuxtjs/ssr/nuxt.config.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2025-07-15',
|
||||
devtools: { enabled: true },
|
||||
|
||||
// Runtime env vars (read at server startup, can change without rebuild)
|
||||
// Nuxt auto-maps NUXT_<key> for private and NUXT_PUBLIC_<key> for public vars
|
||||
runtimeConfig: {
|
||||
runtimePrivateVar: process.env.NUXT_RUNTIME_PRIVATE_VAR || 'default-value',
|
||||
public: {
|
||||
runtimePublicVar: process.env.NUXT_PUBLIC_RUNTIME_PUBLIC_VAR || 'default-value',
|
||||
},
|
||||
},
|
||||
|
||||
// Build-time env var (baked into bundle at build, public only)
|
||||
vite: {
|
||||
define: {
|
||||
'import.meta.env.BUILD_PUBLIC_VAR': JSON.stringify(process.env.BUILD_PUBLIC_VAR || 'default-value'),
|
||||
},
|
||||
},
|
||||
})
|
||||
9509
node/nuxtjs/ssr/package-lock.json
generated
Normal file
9509
node/nuxtjs/ssr/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
node/nuxtjs/ssr/package.json
Normal file
17
node/nuxtjs/ssr/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "ssr",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt": "^4.2.1",
|
||||
"vue": "^3.5.25",
|
||||
"vue-router": "^4.6.3"
|
||||
}
|
||||
}
|
||||
6441
node/nuxtjs/ssr/pnpm-lock.yaml
generated
Normal file
6441
node/nuxtjs/ssr/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
BIN
node/nuxtjs/ssr/public/favicon.ico
Normal file
BIN
node/nuxtjs/ssr/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
2
node/nuxtjs/ssr/public/robots.txt
Normal file
2
node/nuxtjs/ssr/public/robots.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
User-Agent: *
|
||||
Disallow:
|
||||
20
node/nuxtjs/ssr/server/api/env.get.ts
Normal file
20
node/nuxtjs/ssr/server/api/env.get.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default defineEventHandler((event) => {
|
||||
const config = useRuntimeConfig(event);
|
||||
|
||||
// Build-time var (public only)
|
||||
const buildPublicVar = import.meta.env.BUILD_PUBLIC_VAR || 'default-value';
|
||||
|
||||
// Log on server
|
||||
console.log('=== Build-time Variables ===');
|
||||
console.log('BUILD_PUBLIC_VAR:', buildPublicVar);
|
||||
console.log('=== Runtime Variables ===');
|
||||
console.log('NUXT_RUNTIME_PRIVATE_VAR:', config.runtimePrivateVar);
|
||||
console.log('NUXT_PUBLIC_RUNTIME_PUBLIC_VAR:', config.public.runtimePublicVar);
|
||||
|
||||
// Return all (in real app, don't expose private vars!)
|
||||
return {
|
||||
buildPublicVar,
|
||||
runtimePrivateVar: config.runtimePrivateVar,
|
||||
runtimePublicVar: config.public.runtimePublicVar,
|
||||
};
|
||||
});
|
||||
18
node/nuxtjs/ssr/tsconfig.json
Normal file
18
node/nuxtjs/ssr/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"files": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./.nuxt/tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./.nuxt/tsconfig.server.json"
|
||||
},
|
||||
{
|
||||
"path": "./.nuxt/tsconfig.shared.json"
|
||||
},
|
||||
{
|
||||
"path": "./.nuxt/tsconfig.node.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user