Skip to content

Commit

Permalink
add container build
Browse files Browse the repository at this point in the history
  • Loading branch information
guregu committed Aug 18, 2022
1 parent 4787151 commit 59763d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
26 changes: 23 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,33 @@ ifndef SPINCFG
SPINCFG = spin.toml
endif

all: local
ifndef SPINVER
SPINVER = v0.4.0
endif

ifndef ARCH
ARCH = amd64
endif

ifndef OS
OS = linux
endif

local: wasm/tpl.wasm
ifndef SPINBIN
SPINBIN = https://github.com/fermyon/spin/releases/download/$(SPINVER)/spin-$(SPINVER)-$(OS)-$(ARCH).tar.gz
endif

.PHONY: run watch deploy container

all: run
run: wasm/tpl.wasm
sh -c '$(SPINFLAGS) spin up --file $(SPINCFG)'

watch: wasm/tpl.wasm
nodemon --watch cgi-bin --watch www --watch lib --ext pl,html,php --verbose --legacy-watch --signal SIGINT --exec '$(SPINFLAGS) spin up --file $(SPINCFG)'

container:
nixpacks build . --name php --pkgs wget --install-cmd 'wget -O spin.tar.gz $(SPINBIN) && tar xvf spin.tar.gz' --start-cmd './spin up --file spin.toml'

deploy: wasm/tpl.wasm
ssh ubuntu@php.energy 'cd php && git pull && sudo systemctl restart php'
ssh ubuntu@php.energy 'cd php && git pull && sudo systemctl restart php'
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Head on over to our beautiful homepage at [php.energy](https://php.energy/). Sou

0. ~~Reconsider whether you really want to do this~~.
1. [Install Spin](https://spin.fermyon.dev/quickstart/).
1. For hot reloading, [install nodemon](https://www.npmjs.com/package/nodemon) (optional).
2. For hot reloading, [install nodemon](https://www.npmjs.com/package/nodemon) (optional).
3. For building the container image, [install nixpacks](https://nixpacks.com/docs/getting-started).
2. Clone this repo.
3. Configure the www root in `spin.toml`
4. Put PHP scripts or Prolog programs in `public_html` or `cgi-bin`.
Expand All @@ -22,6 +23,11 @@ Head on over to our beautiful homepage at [php.energy](https://php.energy/). Sou
- Run server with `make` or `spin up`.
- Or use `make watch` for hot reloading.

## Build
1. [Install nixpacks](https://nixpacks.com/docs/getting-started).
2. Build a Docker container image with `make container`.
3. See Makefile for settings.

## How does it work?

It just runs the WebAssembly version of Trealla Prolog and writes CGI ([RFC 3875](https://datatracker.ietf.org/doc/html/rfc3875)) output to stdout.
Expand Down

0 comments on commit 59763d4

Please sign in to comment.