Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,38 @@ jobs:
git --no-pager log ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
nix develop . --command cog check ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}

build-docker:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
statuses: write
steps:
- uses: actions/checkout@v5
- uses: DeterminateSystems/determinate-nix-action@v3
- name: Build site
run: |
nix build --print-build-logs
mkdir dist
cp -r --no-preserve=mode,ownership,timestamps result/* dist/

- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: deploy/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

success:
if: always()
runs-on: ubuntu-latest
Expand All @@ -44,6 +76,7 @@ jobs:
- eslint
- cog
- tsc
- build-docker

steps:
- name: Check other jovs
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/deploy.yml

This file was deleted.

11 changes: 11 additions & 0 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nginx:stable-alpine-slim

RUN sed -i '1idaemon off;' /etc/nginx/nginx.conf
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf

# Copy your built application files into the NGINX serving directory
ADD dist/ /app

# The base image handles the standard SPA routing config
EXPOSE 80
CMD ["nginx"]
25 changes: 25 additions & 0 deletions deploy/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80 default_server;

gzip on;
gzip_min_length 1000;
gzip_types text/plain text/xml application/javascript text/css;

root /app;

# normal routes
# serve given url and default to index.html if not found
# e.g. /, /user and /foo/bar will return index.html
location / {
add_header Cache-Control "no-store";
try_files $uri $uri/index.html /index.html;
}

# files
# for all routes matching a dot, check for files and return 404 if not found
# e.g. /file.js returns a 404 if not found
location ~ \.(?!html) {
add_header Cache-Control "public, max-age=2678400";
try_files $uri =404;
}
}
39 changes: 1 addition & 38 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 53 additions & 62 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,86 +1,77 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/x86_64-linux";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
};

outputs =
{
self,
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
nativeBuildInputs = with pkgs; [
nodejs_25
nodePackages.typescript
nodePackages.typescript-language-server
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
nativeBuildInputs = with pkgs; [
nodejs_25
nodePackages.typescript
nodePackages.typescript-language-server

cocogitto
];
npmDepsHash = "sha256-XAzDSXub5xLzoUYXosH2Gqy9De0bzOgfoyOB4jFUKJU=";
in
{
devShells.default = pkgs.mkShell {
inherit nativeBuildInputs;
};
cocogitto
];
npmDepsHash = "sha256-XAzDSXub5xLzoUYXosH2Gqy9De0bzOgfoyOB4jFUKJU=";
in
{
devShells.${system}.default = pkgs.mkShell {
inherit nativeBuildInputs;
};

packages.default = pkgs.buildNpmPackage {
name = "blog";
packages.${system}.default = pkgs.buildNpmPackage {
name = "blog";

src = self;
src = self;

buildPhase = ''
npm run build
'';
buildPhase = ''
npm run build
'';

installPhase = ''
mkdir $out
cp -r dist/* $out
cp netlify.toml $out
'';
installPhase = ''
mkdir $out
cp -r dist/* $out
'';

inherit nativeBuildInputs npmDepsHash;
};
inherit nativeBuildInputs npmDepsHash;
};

checks =
let
common = {
src = self;
buildPhase = "";
doCheck = true;
dontBuild = true;
installPhase = "mkdir $out";
checks.${system} =
let
common = {
src = self;
buildPhase = "";
doCheck = true;
dontBuild = true;
installPhase = "mkdir $out";

inherit nativeBuildInputs npmDepsHash;
};
mkCheck = args: pkgs.buildNpmPackage (args // common);
in
{
eslint = mkCheck {
name = "eslint-check";
inherit nativeBuildInputs npmDepsHash;
};
mkCheck = args: pkgs.buildNpmPackage (args // common);
in
{
eslint = mkCheck {
name = "eslint-check";

checkPhase = ''
npx eslint src
'';
};
tsc = mkCheck {
name = "eslint-check";
checkPhase = ''
npx eslint src
'';
};
tsc = mkCheck {
name = "eslint-check";

checkPhase = ''
tsc
'';
};
checkPhase = ''
tsc
'';
};
}
);
};
};

}
Loading