Skip to content

Commit 59763d4

Browse files
committed
add container build
1 parent 4787151 commit 59763d4

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

Makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,33 @@ ifndef SPINCFG
77
SPINCFG = spin.toml
88
endif
99

10-
all: local
10+
ifndef SPINVER
11+
SPINVER = v0.4.0
12+
endif
13+
14+
ifndef ARCH
15+
ARCH = amd64
16+
endif
17+
18+
ifndef OS
19+
OS = linux
20+
endif
1121

12-
local: wasm/tpl.wasm
22+
ifndef SPINBIN
23+
SPINBIN = https://github.com/fermyon/spin/releases/download/$(SPINVER)/spin-$(SPINVER)-$(OS)-$(ARCH).tar.gz
24+
endif
25+
26+
.PHONY: run watch deploy container
27+
28+
all: run
29+
run: wasm/tpl.wasm
1330
sh -c '$(SPINFLAGS) spin up --file $(SPINCFG)'
1431

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

35+
container:
36+
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'
37+
1838
deploy: wasm/tpl.wasm
19-
ssh ubuntu@php.energy 'cd php && git pull && sudo systemctl restart php'
39+
ssh ubuntu@php.energy 'cd php && git pull && sudo systemctl restart php'

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Head on over to our beautiful homepage at [php.energy](https://php.energy/). Sou
1313

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

26+
## Build
27+
1. [Install nixpacks](https://nixpacks.com/docs/getting-started).
28+
2. Build a Docker container image with `make container`.
29+
3. See Makefile for settings.
30+
2531
## How does it work?
2632

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

0 commit comments

Comments
 (0)