Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
feat: compile the project to ARM 64-bits too (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Angel M De Miguel <[email protected]>
  • Loading branch information
Angelmmiguel authored Aug 29, 2022
1 parent 94caaf7 commit 1a7471a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pi-zero-ssr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ all: build

build: build-client build-ssr build-handler pack

build-64: build-client build-ssr build-handler-64 pack

dev: build-client build-ssr build-handler-dev run

build-client:
Expand All @@ -16,6 +18,9 @@ build-handler-dev:
build-handler:
make -C ./handler build && mv ./handler/ssr-handler ./

build-handler-64:
make -C ./handler build-64 && mv ./handler/ssr-handler ./

pack:
tar czf build.tar.gz ssr-handler ssr.wasm dist

Expand Down
11 changes: 7 additions & 4 deletions pi-zero-ssr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This project is a PreactJS application running in the browser (client) and a ser
* [Vite](https://vitejs.dev/)
* [MDX](https://mdxjs.com/)

The challenge of this project was to run the server inside a [Raspberry Pi Zero W](https://www.raspberrypi.com/products/raspberry-pi-zero-w/). This small board integrates a BCM2835 (ARM 32-Bits / 1GHz) chipset and 512MB of SRAM. These restrictions made it an interesting project.
The challenge of this project was to run the server inside a [Raspberry Pi Zero W](https://www.raspberrypi.com/products/raspberry-pi-zero-w/) and [Pi Zero 2 W](https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/). These small boards integrate a BCM2835 (ARM 32-Bits / 1GHz) and BCM2710A1 (ARM 64-bits / Quad core 1GHz) respectively. Both include 512MB of SRAM. These restrictions make them an interesting project.

These are the details of the SSR logic:

Expand Down Expand Up @@ -56,17 +56,20 @@ This project is composed by different parts. This section aims to introduce them
* The `handler` folder includes the Go HTTP handler and runtime. This project uses [Wazero](https://wazero.io/) to instantiate and run the WebAssembly module
* The `Makefile` calls the different tools to build the project

## Deployment to a Raspberry Pi Zero W
## Deployment to a Raspberry Pi Zero

To deploy this project to a Raspberry Pi Zero W, you need first to compile it. For that, you will need a Linux machine that includes the tooling in the "Prerequisites" section.

Then, run the following command:

```
# 32-bits / Raspberry Pi Zero
make build
# 64-bits / Raspberry Pi Zero 2
make build-64
```

This command will create a final `build.tar.gz` file in the project root folder. Then, you need to run the following commands to start serving the site in the Raspberry Pi Zero W:
This command will create a final `build.tar.gz` file in the project root folder. Then, you need to run the following commands to start serving the site in the Raspberry Pi Zero 1 / 2:

```
scp ./build.tar.gz pi@PI_ZERO_IP_ADDRESS:~
Expand All @@ -79,7 +82,7 @@ tar xvf build.tar.gz

Then, you can access to the site in <http://PI_ZERO_IP_ADDRESS:8080>.

Note that it takes some time to boot the server (~10s) and to prerender the pages (~5-15s). This is one of the further exploration topics around this project.
Note that it takes some time to boot the server and to prerender the pages. This is one of the further exploration topics around this project.

## Let's keep in touch

Expand Down
2 changes: 2 additions & 0 deletions pi-zero-ssr/handler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ build-dev:
go build .
build:
GOARCH=arm GOARM=6 go build .
build-64:
GOARCH=arm64 go build .

0 comments on commit 1a7471a

Please sign in to comment.