Skip to content

Commit

Permalink
updated to astro 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
harrybrwn committed Jan 25, 2023
1 parent c080ac4 commit 5e673fd
Show file tree
Hide file tree
Showing 9 changed files with 477 additions and 670 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
dist/
*.tar.gz
*.zip
.astro
.vercel

# dependencies
node_modules/
Expand Down
21 changes: 19 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,35 @@ COPY astro.config.mjs tsconfig.json .
COPY src/ src
COPY public/ public
COPY content/ content
RUN yarn astro sync

FROM builder as server-builder
COPY . .
RUN yarn build:server

FROM builder as static-builder
RUN yarn build

#
# Static files
#
FROM scratch as static
COPY --from=builder /opt/harrybrwn.github.io/dist /
COPY --from=static-builder /opt/harrybrwn.github.io/dist /

#
# Nginx
#
FROM nginx:${NGINX_VERSION} as nginx
COPY --from=builder /opt/harrybrwn.github.io/dist /var/www/harrybrwn.github.io
COPY --from=static-builder /opt/harrybrwn.github.io/dist /var/www/harrybrwn.github.io
COPY config/nginx.conf /etc/nginx/nginx.conf
#RUN sed -i 's/Server: nginx/Server: yeetyboi/g' /usr/sbin/nginx

#
# Server
#
FROM node:${NODE_VERSION} as server
WORKDIR /opt/harrybrwn.github.io/
COPY --from=server-builder /opt/harrybrwn.github.io .
RUN ls -la
ENTRYPOINT ["node"]
CMD ["dist/server/entry.mjs"]
14 changes: 11 additions & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import { defineConfig } from "astro/config";
import path from "path";
import fs from "fs";

import node from "@astrojs/node";

import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import solid from "@astrojs/solid-js";
import purgecss from "astro-purgecss";
import compress from "./src/lib/configHelpers.js";
import obsidian from "@astro.hrry.dev/obsidian";
import ViteYaml from "@modyfi/vite-plugin-yaml";
import compress from "./src/lib/configHelpers.js";
import { gardenBasePath } from "./src/config";

const domain = fs.readFileSync("public/CNAME").toString().trim();
const site = `https://${domain}`;
const outDir = "./dist";
const siteMapFilter = new Set(["admin"]);

const output = process.env.ASTRO_OUTPUT || "static";

// https://astro.build/config
export default defineConfig({
site: site,
outDir: outDir,
output: output,
adapter: output === "server" ? node({ mode: "standalone" }) : undefined,
build: {
assets: "a",
},
markdown: {
syntaxHighlight: "prism",
},
Expand All @@ -30,9 +40,7 @@ export default defineConfig({
rollupOptions: {
output: {
entryFileNames: "[hash].js",
// "a" for "assets"
assetFileNames: "a/[hash][extname]",
//assetFileNames: "a/[name].[hash][extname]",
},
},
// https://github.com/Ernxst/astro-cssbundle
Expand Down
7 changes: 7 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ target "nginx" {
labels = labels()
tags = tags("harrybrwn/harrybrwn.github.io-nginx")
args = args()
}

target "server" {
target = "server"
labels = labels()
tags = tags("harrybrwn/harrybrwn.github.io-server")
args = args()
}
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"scripts": {
"dev": "node scripts/generate.js && astro dev",
"build": "astro build",
"build:server": "ASTRO_OUTPUT=server astro build",
"preview": "astro preview",
"preview:server": "ASTRO_OUTPUT=server astro preview",
"astro": "astro",
"clean": "rm -rf ./dist *.tar.gz *.zip",
"package": "scripts/package.sh",
Expand All @@ -26,13 +28,13 @@
"@astro.hrry.dev/obsidian": "0.0.1",
"@astro.hrry.dev/robots.txt": "0.0.1",
"@astro.hrry.dev/wikilink": "0.0.1",
"@astrojs/cloudflare": "^5.0.0",
"@astrojs/mdx": "^0.13.0",
"@astrojs/node": "^4.0.0",
"@astrojs/rss": "^1.2.1",
"@astrojs/cloudflare": "^6.0.0",
"@astrojs/mdx": "^0.15.0",
"@astrojs/node": "^5.0.0",
"@astrojs/rss": "^2.1.0",
"@astrojs/sitemap": "^1.0.0",
"@astrojs/solid-js": "^1.2.3",
"astro": "^1.7.0",
"@astrojs/solid-js": "^2.0.0",
"astro": "^2.0.0",
"astro-compress": "^1.1.24",
"astro-purgecss": "^1.3.1",
"github-slugger": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

interface ImportMetaEnv {
Expand Down
2 changes: 1 addition & 1 deletion src/modified.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"2023-01-11T04:58:30.000Z"
],
"content/Free Will.md": [
"2023-01-24T17:13:23.865Z"
"2023-01-25T01:23:17.115Z"
],
"content/GPG.md": [
"2023-01-12T18:21:03.000Z"
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"types": [
"@modyfi/vite-plugin-yaml/modules"
],
"strictNullChecks": true,
"jsx": "preserve",
"jsxImportSource": "solid-js"
}
Expand Down
Loading

0 comments on commit 5e673fd

Please sign in to comment.