chore: update nuxt examples

This commit is contained in:
Cinzya
2025-12-28 19:11:25 +01:00
parent be12308526
commit 55fe4b24cf
25 changed files with 12333 additions and 11274 deletions

View File

@@ -1,6 +0,0 @@
{
"name": "nuxt",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}

14
nuxt/server/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM node:24 AS build
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:24
WORKDIR /app
COPY --from=build /app/.output/ ./
ENV PORT=3000
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["node", "/app/server/index.mjs"]

View File

@@ -1,6 +1,40 @@
# Coolify Configuration # Coolify Configuration
1. Use `Nixpacks`. ## Dockerfile
2. Set `Ports Exposed` to `3000` (or any port you set).
3. Set `Start Command` to `node .output/server/index.mjs` 1. Create a `Dockerfile` in the root of your project with the following content:
```Dockerfile
FROM node:24 AS build
WORKDIR /app
COPY package.json package-lock.json\* ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:24
WORKDIR /app
COPY --from=build /app/.output/ ./
ENV PORT=3000
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["node", "/app/server/index.mjs"]
```
2. Select `Dockerfile` as the `Build Pack` in Coolify.
3. Set `Ports Exposed` to `3000` (or any port you set).
4. Set `Dockerfile Location` to the location of your `Dockerfile` (e.g., `/Dockerfile`).
## Nixpacks
1. Create a `nixpacks.toml` file in the root of your project with the following content:
```toml
[phases.setup]
nixpkgsArchive = '51ad838b03a05b1de6f9f2a0fffecee64a9788ee'
```
2. Select `Nixpacks` as the `Build Pack` in Coolify.
3. Set `Ports Exposed` to `3000` (or any port you set).
4. Set `Start Command` to `node .output/server/index.mjs`
- Alternatively, you can set the `start` script inside `package.json` to `node .output/server/index.mjs`. Then Nixpacks will automatically use it as the start command. - Alternatively, you can set the `start` script inside `package.json` to `node .output/server/index.mjs`. Then Nixpacks will automatically use it as the start command.

View File

@@ -1,5 +1,6 @@
<template> <template>
<div> <div>
<NuxtRouteAnnouncer />
<NuxtWelcome /> <NuxtWelcome />
</div> </div>
</template> </template>

View File

@@ -0,0 +1,2 @@
[phases.setup]
nixpkgsArchive = '51ad838b03a05b1de6f9f2a0fffecee64a9788ee'

View File

@@ -1,4 +1,5 @@
// https://nuxt.com/docs/api/configuration/nuxt-config // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({ export default defineNuxtConfig({
compatibilityDate: '2025-07-15',
devtools: { enabled: true } devtools: { enabled: true }
}) })

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "nuxt-app", "name": "nuxt-app",
"private": true,
"type": "module", "type": "module",
"private": true,
"scripts": { "scripts": {
"build": "nuxt build", "build": "nuxt build",
"dev": "nuxt dev", "dev": "nuxt dev",
@@ -11,8 +11,8 @@
"start": "node .output/server/index.mjs" "start": "node .output/server/index.mjs"
}, },
"dependencies": { "dependencies": {
"nuxt": "^3.10.3", "nuxt": "^4.2.2",
"vue": "^3.4.19", "vue": "^3.5.26",
"vue-router": "^4.3.0" "vue-router": "^4.6.4"
} }
} }

View File

@@ -0,0 +1,2 @@
User-Agent: *
Disallow:

View File

@@ -1,3 +0,0 @@
export default defineEventHandler((event) => {
return 'OK'
})

View File

@@ -1,3 +0,0 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

View File

@@ -1,4 +1,18 @@
{ {
// https://nuxt.com/docs/guide/concepts/typescript // https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json" "files": [],
"references": [
{
"path": "./.nuxt/tsconfig.app.json"
},
{
"path": "./.nuxt/tsconfig.server.json"
},
{
"path": "./.nuxt/tsconfig.shared.json"
},
{
"path": "./.nuxt/tsconfig.node.json"
}
]
} }

View File

@@ -5,7 +5,6 @@
.nitro .nitro
.cache .cache
dist dist
.env
# Node dependencies # Node dependencies
node_modules node_modules

11
nuxt/static/Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM node:24 AS build
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .
RUN npm run generate
FROM nginx
COPY --from=build /app/.output/public /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -2,6 +2,37 @@
Check [nuxt.config.js](./nuxt.config.js). Check [nuxt.config.js](./nuxt.config.js).
1. Use `Nixpacks`. ## Dockerfile
2. Turn on `Is it a static site?`.
1. Create a `Dockerfile` in the root of your project with the following content:
```Dockerfile
FROM node:24 AS build
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .
RUN npm run generate
FROM nginx
COPY --from=build /app/.output/public /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
```
2. Select `Dockerfile` as the `Build Pack` in Coolify.
3. Set `Ports Exposed` to `80`.
## Nixpacks
1. Create a `nixpacks.toml` file in the root of your project with the following content:
```toml
[phases.setup]
nixpkgsArchive = '51ad838b03a05b1de6f9f2a0fffecee64a9788ee'
aptPkgs = ["openssh-client"]
```
2. Select `Nixpacks` as the `Build Pack` in Coolify.
3. Turn on `Is it a static site?`.
4. Set `Publish Directory` to `/.output/public`. 4. Set `Publish Directory` to `/.output/public`.

View File

@@ -1,13 +0,0 @@
<template>
<div>
<div style="padding: 20px; background: #f0f0f0; margin: 20px; border-radius: 8px;">
<h2>APP_URL:</h2>
<p>{{ config.public.appUrl }}</p>
</div>
<NuxtWelcome />
</div>
</template>
<script setup>
const config = useRuntimeConfig()
</script>

6
nuxt/static/app/app.vue Normal file
View File

@@ -0,0 +1,6 @@
<template>
<div>
<NuxtRouteAnnouncer />
<NuxtWelcome />
</div>
</template>

View File

@@ -1,31 +0,0 @@
#!/bin/bash
set -e
# Validate SSH private key
if [ -n "$KEY" ]; then
echo "Validating SSH private key..."
# Create .ssh directory if it doesn't exist
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Write key to file
echo "$KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat ~/.ssh/id_rsa
# Validate the key
ssh-keygen -y -f ~/.ssh/id_rsa
if [ $? -eq 0 ]; then
echo "✓ SSH private key is valid"
else
echo "✗ SSH private key is invalid"
rm -f ~/.ssh/id_rsa
exit 1
fi
else
echo "⚠ KEY environment variable not set, skipping validation"
fi
# Continue with build
nuxt build

View File

@@ -1,2 +1,2 @@
[phases.setup] [phases.setup]
aptPkgs = ["openssh-client"] nixpkgsArchive = '51ad838b03a05b1de6f9f2a0fffecee64a9788ee'

View File

@@ -1,9 +1,16 @@
// https://nuxt.com/docs/api/configuration/nuxt-config // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({ export default defineNuxtConfig({
compatibilityDate: "2025-07-15",
devtools: { enabled: true }, devtools: { enabled: true },
nitro: {
prerender: {
crawlLinks: true,
routes: ["/"],
},
},
runtimeConfig: { runtimeConfig: {
public: { public: {
appUrl: process.env.APP_URL || 'something' appUrl: process.env.APP_URL || "something",
} },
} },
}) });

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
{ {
"name": "nuxt-app", "name": "nuxt-app",
"private": true,
"type": "module", "type": "module",
"private": true,
"scripts": { "scripts": {
"build": "./build.sh", "build": "nuxt build",
"dev": "nuxt dev", "dev": "nuxt dev",
"generate": "nuxt generate", "generate": "nuxt generate",
"preview": "nuxt preview", "preview": "nuxt preview",
@@ -11,8 +11,8 @@
"start": "node .output/server/index.mjs" "start": "node .output/server/index.mjs"
}, },
"dependencies": { "dependencies": {
"nuxt": "^3.10.3", "nuxt": "^4.2.2",
"vue": "^3.4.19", "vue": "^3.5.26",
"vue-router": "^4.3.0" "vue-router": "^4.6.4"
} }
} }

View File

@@ -0,0 +1,2 @@
User-Agent: *
Disallow:

View File

@@ -1,3 +0,0 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

View File

@@ -1,4 +1,18 @@
{ {
// https://nuxt.com/docs/guide/concepts/typescript // https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json" "files": [],
"references": [
{
"path": "./.nuxt/tsconfig.app.json"
},
{
"path": "./.nuxt/tsconfig.server.json"
},
{
"path": "./.nuxt/tsconfig.shared.json"
},
{
"path": "./.nuxt/tsconfig.node.json"
}
]
} }