This commit is contained in:
35
.github/workflows/deploy.yml
vendored
35
.github/workflows/deploy.yml
vendored
@@ -1,10 +1,9 @@
|
|||||||
name: Build and Deploy
|
name: Docker Deploy
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -13,30 +12,24 @@ jobs:
|
|||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Nix
|
- name: Set up Docker Buildx
|
||||||
uses: cachix/install-nix-action@v26
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
extra_nix_config: |
|
|
||||||
experimental-features = nix-command flakes
|
|
||||||
|
|
||||||
- name: Build container image
|
|
||||||
run: |
|
|
||||||
nix build --impure --print-build-logs
|
|
||||||
docker load < result
|
|
||||||
|
|
||||||
- name: Login to Container Registry
|
- name: Login to Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.REPO_HOST }}
|
registry: ${{ secrets.REPO_HOST }}
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.DEPLOY_TOKEN }}
|
password: ${{ secrets.DEPLOY_TOKEN }}
|
||||||
|
|
||||||
- name: Tag and push images
|
- name: Build and push
|
||||||
run: |
|
uses: docker/build-push-action@v4
|
||||||
docker tag atashdotdev:latest ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
|
with:
|
||||||
docker tag atashdotdev:latest ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
context: .
|
||||||
docker push ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
|
platforms: linux/amd64
|
||||||
docker push ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
|
||||||
|
${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
# Atash Website
|
# Atash Website
|
||||||
|
|
||||||
This project requires Nix with Flakes enabled.
|
:)
|
||||||
|
|
||||||
Run ```nix develop``` in order to install dependencies. Then, use pnpm as normal.
|
|
||||||
|
|||||||
61
flake.lock
generated
61
flake.lock
generated
@@ -1,61 +0,0 @@
|
|||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1753250450,
|
|
||||||
"narHash": "sha256-i+CQV2rPmP8wHxj0aq4siYyohHwVlsh40kV89f3nw1s=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "fc02ee70efb805d3b2865908a13ddd4474557ecf",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
84
flake.nix
84
flake.nix
@@ -1,84 +0,0 @@
|
|||||||
{
|
|
||||||
description = "Development environment for atashdotdev with Node and pnpm";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
version = (pkgs.lib.importJSON ./package.json).version;
|
|
||||||
|
|
||||||
app = pkgs.stdenv.mkDerivation {
|
|
||||||
pname = "atashdotdev";
|
|
||||||
inherit version;
|
|
||||||
src = ./.;
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [ nodejs_24 nodePackages.pnpm cacert ];
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
export HOME=$TMPDIR
|
|
||||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
pnpm build
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/lib/app
|
|
||||||
cp -r dist package.json pnpm-lock.yaml $out/lib/app/
|
|
||||||
cd $out/lib/app && pnpm install --prod --frozen-lockfile
|
|
||||||
|
|
||||||
mkdir -p $out/bin
|
|
||||||
echo '#!/bin/sh
|
|
||||||
cd $out/lib/app
|
|
||||||
exec ${pkgs.nodejs_24}/bin/node ./dist/server/entry.mjs "$@"' > $out/bin/atashdotdev
|
|
||||||
chmod +x $out/bin/atashdotdev
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# Dev shell
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [ nodejs_24 nodePackages.pnpm ];
|
|
||||||
shellHook = ''
|
|
||||||
echo "🚀 atashdotdev development environment loaded!"
|
|
||||||
echo "Node version: $(node --version)"
|
|
||||||
echo "pnpm version: $(pnpm --version)"
|
|
||||||
|
|
||||||
if [ ! -d "node_modules" ]; then
|
|
||||||
echo "📦 Installing pnpm dependencies..."
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# nix run - run the dev server
|
|
||||||
apps.default = {
|
|
||||||
type = "app";
|
|
||||||
program = "${pkgs.writeShellScript "dev" ''
|
|
||||||
export PATH="${pkgs.nodejs_24}/bin:${pkgs.nodePackages.pnpm}/bin:$PATH"
|
|
||||||
if [ ! -d "node_modules" ]; then
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
fi
|
|
||||||
pnpm dev
|
|
||||||
''}";
|
|
||||||
};
|
|
||||||
|
|
||||||
# nix build - build the container
|
|
||||||
packages.default = pkgs.dockerTools.buildLayeredImage {
|
|
||||||
name = "atashdotdev";
|
|
||||||
tag = "latest";
|
|
||||||
contents = with pkgs; [ app nodejs_24 bash coreutils ];
|
|
||||||
config = {
|
|
||||||
Cmd = [ "${app}/bin/atashdotdev" ];
|
|
||||||
ExposedPorts."4321/tcp" = {};
|
|
||||||
Env = [ "NODE_ENV=production" "HOST=0.0.0.0" "PORT=4321" ];
|
|
||||||
WorkingDir = "${app}/lib/app";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"nix:run": "nix develop",
|
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user