mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-10-01 20:33:50 +00:00
ops: deploy logicsrc.com to dev2 on merge (#215)
Railway deployed this on push; dev2 does not by itself. The workflow ssh's to the box and runs /home/anthony/www/logicsrc.com/deploy-app.sh, which builds the image from this checkout and restarts the compose stack. Generated by cli-tools dev2/dev2-site scaffold. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
c434a65272
commit
f4780259fd
4 changed files with 118 additions and 0 deletions
60
.github/workflows/deploy-dev2-logicsrc-com.yml
vendored
Normal file
60
.github/workflows/deploy-dev2-logicsrc-com.yml
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Ship every merge to dev2, where logicsrc.com runs since it left Railway (which
|
||||||
|
# deployed on merge by itself). The box pulls the merged commit, rebuilds the
|
||||||
|
# image(s) from this repo and restarts the compose stack under
|
||||||
|
# /home/anthony/www/logicsrc.com. Generated by cli-tools/dev2/dev2-site scaffold.
|
||||||
|
name: Deploy to dev2
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
description: Git ref to deploy (defaults to the pushed commit)
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: deploy-dev2
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 45
|
||||||
|
steps:
|
||||||
|
# ${{ }} values go through env, never straight into a run: body.
|
||||||
|
- name: Resolve target revision
|
||||||
|
id: rev
|
||||||
|
env:
|
||||||
|
REF: ${{ inputs.ref || github.sha }}
|
||||||
|
run: echo "sha=$REF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Set up ssh
|
||||||
|
env:
|
||||||
|
SSH_KEY: ${{ secrets.DEV2_SSH_KEY }}
|
||||||
|
KNOWN_HOSTS: ${{ secrets.DEV2_KNOWN_HOSTS }}
|
||||||
|
run: |
|
||||||
|
install -d -m 700 ~/.ssh
|
||||||
|
printf '%s\n' "$SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
printf '%s\n' "$KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||||
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
env:
|
||||||
|
DEV2_USER: ${{ secrets.DEV2_USER }}
|
||||||
|
DEV2_HOST: ${{ secrets.DEV2_HOST }}
|
||||||
|
SHA: ${{ steps.rev.outputs.sha }}
|
||||||
|
run: |
|
||||||
|
ssh -o BatchMode=yes "$DEV2_USER@$DEV2_HOST" \
|
||||||
|
/home/anthony/www/logicsrc.com/deploy-app.sh "$SHA"
|
||||||
|
|
||||||
|
- name: Verify the site answers
|
||||||
|
run: |
|
||||||
|
for i in $(seq 1 10); do
|
||||||
|
code=$(curl -s -o /dev/null -w '%{http_code}' "https://logicsrc.com/" || true)
|
||||||
|
case "$code" in 2*|3*|401|403) echo "logicsrc.com $code"; exit 0;; esac
|
||||||
|
echo "attempt $i: $code"; sleep 10
|
||||||
|
done
|
||||||
|
echo "logicsrc.com never answered"; exit 1
|
||||||
36
.nixpacks/Dockerfile
Normal file
36
.nixpacks/Dockerfile
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
FROM ghcr.io/railwayapp/nixpacks:ubuntu-1745885067
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash", "-l", "-c"]
|
||||||
|
WORKDIR /app/
|
||||||
|
ARG PUBLIC_URL
|
||||||
|
ENV PUBLIC_URL=$PUBLIC_URL
|
||||||
|
|
||||||
|
|
||||||
|
COPY .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix
|
||||||
|
RUN nix-env -if .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix && nix-collect-garbage -d
|
||||||
|
|
||||||
|
|
||||||
|
ARG CI NIXPACKS_METADATA NIXPACKS_NODE_VERSION NODE_ENV NPM_CONFIG_PRODUCTION
|
||||||
|
ENV CI=$CI NIXPACKS_METADATA=$NIXPACKS_METADATA NIXPACKS_NODE_VERSION=$NIXPACKS_NODE_VERSION NODE_ENV=$NODE_ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION
|
||||||
|
|
||||||
|
# setup phase
|
||||||
|
# noop
|
||||||
|
|
||||||
|
# install phase
|
||||||
|
ENV NIXPACKS_PATH=/app/node_modules/.bin:$NIXPACKS_PATH
|
||||||
|
COPY . /app/.
|
||||||
|
RUN --mount=type=cache,id=myZsC0wNW9Q-/root/npm,target=/root/.npm npm ci
|
||||||
|
|
||||||
|
# build phase
|
||||||
|
COPY . /app/.
|
||||||
|
RUN --mount=type=cache,id=myZsC0wNW9Q-apps/logicsrc-web/next/cache,target=/app/apps/logicsrc-web/.next/cache --mount=type=cache,id=myZsC0wNW9Q-node_modules/cache,target=/app/node_modules/.cache npm run build
|
||||||
|
|
||||||
|
|
||||||
|
RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile
|
||||||
|
|
||||||
|
|
||||||
|
# start
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
CMD ["npm run start"]
|
||||||
|
|
||||||
1
.nixpacks/build.sh
Normal file
1
.nixpacks/build.sh
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
docker build /home/anthony/src/profullstack/logicsrc/.claude/worktrees/dev2-logicsrc.com-8sr7z6_r -f /home/anthony/src/profullstack/logicsrc/.claude/worktrees/dev2-logicsrc.com-8sr7z6_r/.nixpacks/Dockerfile -t 4c321096-0f24-4fcc-8a9b-8098036fecc1 --build-arg CI=true --build-arg NIXPACKS_METADATA=node --build-arg NIXPACKS_NODE_VERSION=22 --build-arg NODE_ENV=production --build-arg NPM_CONFIG_PRODUCTION=false
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
{ }:
|
||||||
|
|
||||||
|
let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.tar.gz") { overlays = [ (import (builtins.fetchTarball "https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz")) ]; };
|
||||||
|
in with pkgs;
|
||||||
|
let
|
||||||
|
APPEND_LIBRARY_PATH = "${lib.makeLibraryPath [ gcc-unwrapped ] }";
|
||||||
|
myLibraries = writeText "libraries" ''
|
||||||
|
export LD_LIBRARY_PATH="${APPEND_LIBRARY_PATH}:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
buildEnv {
|
||||||
|
name = "ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7-env";
|
||||||
|
paths = [
|
||||||
|
(runCommand "ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7-env" { } ''
|
||||||
|
mkdir -p $out/etc/profile.d
|
||||||
|
cp ${myLibraries} $out/etc/profile.d/ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7-env.sh
|
||||||
|
'')
|
||||||
|
nodejs_22 npm-9_x
|
||||||
|
];
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue