From 5e0d4ffef53c8d0255a7cd6f55ff1ee08c5d961a Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sat, 9 Mar 2024 23:03:52 +0000 Subject: [PATCH] Test fly deployment --- .dockerignore | 21 +++++++++++++++++++ Dockerfile | 49 ++++++++++++++++++++++++++++++++++++++++++++ fly.toml | 22 ++++++++++++++++++++ src/pages/rss.xml.js | 2 +- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 fly.toml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6240da8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# build output +dist/ +# generated types +.astro/ + +# dependencies +node_modules/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9aa3f52 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +# syntax = docker/dockerfile:1 + +# Adjust NODE_VERSION as desired +ARG NODE_VERSION=18.17.0 +FROM node:${NODE_VERSION}-slim as base + +LABEL fly_launch_runtime="Astro" + +# Astro app lives here +WORKDIR /app + +# Set production environment +ENV NODE_ENV="production" + +# Install pnpm +ARG PNPM_VERSION=8.9.2 +RUN npm install -g pnpm@$PNPM_VERSION + + +# Throw-away build stage to reduce size of final image +FROM base as build + +# Install packages needed to build node modules +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 + +# Install node modules +COPY --link package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile --prod=false + +# Copy application code +COPY --link . . + +# Build application +RUN pnpm run build + +# Remove development dependencies +RUN pnpm prune --prod + + +# Final stage for app image +FROM nginx + +# Copy built application +COPY --from=build /app/dist /usr/share/nginx/html + +# Start the server by default, this can be overwritten at runtime +EXPOSE 80 +CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ] diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..409d1a0 --- /dev/null +++ b/fly.toml @@ -0,0 +1,22 @@ +# fly.toml app configuration file generated for kennethnym-website on 2024-03-09T22:59:26Z +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'kennethnym-website' +primary_region = 'lhr' + +[build] + +[http_service] + internal_port = 80 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + memory = '1gb' + cpu_kind = 'shared' + cpus = 1 diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index 2bf6f21..baba9b0 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -1,6 +1,6 @@ import rss from "@astrojs/rss"; import { SITE_TITLE, SITE_DESCRIPTION } from "../consts"; -import { getBlogs } from "../content/blog.js"; +import { getBlogs } from "../content/blog"; export async function GET(context) { const posts = await getBlogs();