Skip to content

Commit c8450a1

Browse files
authored
Merge pull request #1 from playfulprogramming/flyio
Flyio
2 parents f3e9d29 + 4acab8b commit c8450a1

File tree

9 files changed

+148
-13
lines changed

9 files changed

+148
-13
lines changed

Diff for: .dockerignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# build output
2+
dist/
3+
4+
# dependencies
5+
node_modules/
6+
7+
# logs
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
pnpm-debug.log*
12+
13+
14+
# environment variables
15+
.env
16+
.env.production
17+
18+
# macOS-specific files
19+
.DS_Store
20+
.idea/
21+
.eslintcache
22+
.vercel
23+
.puppeteer
24+
25+
.astro
26+
.gitignore

Diff for: .github/workflows/fly-deploy.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
2+
3+
name: Fly Deploy
4+
on:
5+
push:
6+
branches:
7+
- main
8+
jobs:
9+
deploy:
10+
name: Deploy app
11+
runs-on: ubuntu-latest
12+
concurrency: deploy-group # optional: ensure only one action runs at a time
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: superfly/flyctl-actions/setup-flyctl@master
16+
- run: flyctl deploy --remote-only
17+
env:
18+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

Diff for: Dockerfile

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM node:20.11-slim as dependencies
2+
WORKDIR /app
3+
4+
# Install pnpm and build dependencies
5+
RUN npm install -g [email protected] && \
6+
apt-get update -qq && \
7+
apt-get install -y python3 build-essential && \
8+
rm -rf /var/lib/apt/lists/*
9+
10+
# Create the environments directory and env file FIRST
11+
RUN mkdir -p src/environments && \
12+
echo "PLAYWRIGHT_BROWSERS_PATH=/app/pw-browsers" > src/environments/browser-path.env
13+
14+
# Copy package files
15+
COPY package.json pnpm-lock.yaml ./
16+
17+
# Install dependencies and extra packages needed for content generation
18+
ENV PLAYWRIGHT_BROWSERS_PATH=/app/pw-browsers
19+
ENV HUSKY=0
20+
RUN pnpm install && \
21+
pnpm add [email protected] html-escaper kleur && \
22+
pnpm playwright install chromium
23+
24+
# Content generation stage
25+
FROM dependencies as content-builder
26+
WORKDIR /app
27+
28+
# Copy source files
29+
COPY . .
30+
31+
# Copy over the node_modules and Playwright browsers
32+
COPY --from=dependencies /app/node_modules ./node_modules
33+
COPY --from=dependencies /app/pw-browsers ./pw-browsers
34+
COPY --from=dependencies /app/src/environments/browser-path.env ./src/environments/browser-path.env
35+
36+
# First generate the content
37+
RUN pnpm run epub & pnpm run social-previews:build & wait
38+
39+
# Run just the Astro build
40+
RUN pnpm exec astro build --experimental-integrations || if [ -d "dist" ]; then \
41+
exit 0; \
42+
else \
43+
exit 1; \
44+
fi
45+
46+
# Production stage for static files
47+
FROM nginx:alpine
48+
COPY --from=content-builder /app/dist /usr/share/nginx/html
49+
50+
EXPOSE 80
51+
CMD ["nginx", "-g", "daemon off;"]

Diff for: astro.config.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import sitemap from "@astrojs/sitemap";
44
import icon from "astro-icon";
55
import { EnumChangefreq as ChangeFreq } from "sitemap";
66
import { siteUrl } from "./src/constants/site-config";
7-
import vercel from "@astrojs/vercel";
87
import symlink from "symlink-dir";
98
import * as path from "path";
109
import { languages } from "./src/constants/index";
@@ -18,16 +17,15 @@ await symlink(path.resolve("content"), path.resolve("public/content"));
1817

1918
export default defineConfig({
2019
site: siteUrl,
21-
adapter: vercel({
22-
// Uses Vercel's Image Optimization API: https://vercel.com/docs/image-optimization
23-
imageService: true,
24-
imagesConfig: {
25-
sizes: SUPPORTED_IMAGE_SIZES,
26-
domains: [],
27-
formats: ["image/avif", "image/webp"],
20+
output: "static",
21+
image: {
22+
service: {
23+
entrypoint: "astro/assets/services/sharp",
24+
config: {
25+
limitInputPixels: false,
26+
},
2827
},
29-
devImageService: "sharp",
30-
}),
28+
},
3129
integrations: [
3230
icon(),
3331
preact({ compat: true }),

Diff for: fly.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# fly.toml app configuration file generated for playfulprogramming-bak on 2024-12-02T18:59:27-08:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = 'playfulprogramming-bak'
7+
primary_region = 'sjc'
8+
9+
[build]
10+
dockerfile = 'Dockerfile'
11+
12+
[http_service]
13+
internal_port = 80
14+
force_https = true
15+
auto_stop_machines = 'stop'
16+
auto_start_machines = true
17+
min_machines_running = 0
18+
19+
[[vm]]
20+
memory = '1gb'
21+
cpu_kind = 'shared'
22+
cpus = 1

Diff for: nginx.conf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
listen 80;
3+
root /usr/share/nginx/html;
4+
index index.html;
5+
etag on;
6+
7+
location / {
8+
try_files $uri $uri/ /index.html;
9+
add_header Cache-Control "no-cache";
10+
}
11+
12+
# Cache static assets
13+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
14+
expires 1y;
15+
add_header Cache-Control "public, no-transform";
16+
}
17+
}

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"dependencies": {
144144
"@oramacloud/client": "^1.3.18",
145145
"@tanstack/react-query": "^5.45.1",
146+
"html-escaper": "^3.0.3",
146147
"medium-zoom": "^1.0.8",
147148
"preact": "10.23.2",
148149
"react-aria": "^3.31.1",

Diff for: pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/components/image/picture.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import {
55
GetPictureUrls,
66
} from "utils/get-picture";
77
import type { JSX } from "preact";
8-
98
interface PictureProps extends GetPictureOptions {
109
urls?: GetPictureUrls;
11-
alt: string;
12-
class?: string;
10+
alt: string;
11+
class?: string;
1312
pictureAttrs?: JSX.HTMLAttributes<HTMLPictureElement> &
1413
Record<string, unknown>;
1514
imgAttrs?: JSX.HTMLAttributes<HTMLImageElement> & Record<string, unknown>;

0 commit comments

Comments
 (0)