chore: switch to static build with dockerfile
This commit is contained in:
parent
e9e74b3c34
commit
332e5f4d26
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM node:lts AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build -- --mode custom
|
||||||
|
|
||||||
|
FROM nginx:alpine AS runtime
|
||||||
|
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
EXPOSE 8080
|
||||||
37
Dockerfile.ssr
Normal file
37
Dockerfile.ssr
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# base node image
|
||||||
|
FROM node:18-bullseye-slim as base
|
||||||
|
|
||||||
|
# set for base and all layer that inherit from it
|
||||||
|
ENV NODE_ENV production
|
||||||
|
|
||||||
|
# Setup production node_modules
|
||||||
|
FROM base as deps
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ADD package.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Build the app
|
||||||
|
FROM base as build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Finally, build the production image with minimal footprint
|
||||||
|
FROM base as production
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=build /app/package.json ./package.json
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=3000
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD node ./dist/server/entry.mjs
|
||||||
|
|
@ -1,12 +1,6 @@
|
||||||
import { defineConfig } from 'astro/config'
|
import { defineConfig } from 'astro/config';
|
||||||
import sitemap from '@astrojs/sitemap'
|
|
||||||
|
|
||||||
import cloudflare from '@astrojs/cloudflare'
|
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: 'https://nzambello-dev.pages.dev',
|
site: 'https://nzambello.dev',
|
||||||
integrations: [sitemap()],
|
});
|
||||||
output: 'server',
|
|
||||||
adapter: cloudflare({ mode: 'directory' })
|
|
||||||
})
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
25
nginx/nginx.conf
Normal file
25
nginx/nginx.conf
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_min_length 1000;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/index.html $uri.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
package.json
26
package.json
|
|
@ -6,8 +6,7 @@
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"start": "astro dev",
|
"start": "astro dev",
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview-astro": "astro preview",
|
"preview": "astro preview",
|
||||||
"preview": "astro build && wrangler pages dev ./dist",
|
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
@ -37,7 +36,10 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"eslintIgnore": ["/node_modules", "/build"],
|
"eslintIgnore": [
|
||||||
|
"/node_modules",
|
||||||
|
"/build"
|
||||||
|
],
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
|
|
@ -97,19 +99,20 @@
|
||||||
"at-rule-no-unknown": [
|
"at-rule-no-unknown": [
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
"ignoreAtRules": ["extend", "function", "include", "mixin", "return"]
|
"ignoreAtRules": [
|
||||||
|
"extend",
|
||||||
|
"function",
|
||||||
|
"include",
|
||||||
|
"mixin",
|
||||||
|
"return"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/cloudflare": "^6.3.0",
|
|
||||||
"@astrojs/rss": "^2.4.1",
|
|
||||||
"@astrojs/sitemap": "^1.3.0",
|
|
||||||
"@fontsource/ubuntu": "^5.0.2",
|
|
||||||
"@fontsource/ubuntu-mono": "^5.0.2",
|
|
||||||
"@picocss/pico": "^1.5.10",
|
"@picocss/pico": "^1.5.10",
|
||||||
"astro": "^2.5.0"
|
"astro": "2.8.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "17.3.0",
|
"@commitlint/cli": "17.3.0",
|
||||||
|
|
@ -118,7 +121,6 @@
|
||||||
"stylelint": "14.15.0",
|
"stylelint": "14.15.0",
|
||||||
"stylelint-config-idiomatic-order": "9.0.0",
|
"stylelint-config-idiomatic-order": "9.0.0",
|
||||||
"stylelint-config-prettier": "9.0.4",
|
"stylelint-config-prettier": "9.0.4",
|
||||||
"stylelint-config-recommended": "9.0.0",
|
"stylelint-config-recommended": "9.0.0"
|
||||||
"wrangler": "^3.0.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue