-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from clue-labs/make
Add Makefile with build instructions
- Loading branch information
Showing
5 changed files
with
65 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
build: vendor | ||
vendor/bin/sculpin generate | ||
|
||
vendor: composer.json composer.lock | ||
composer install | ||
touch $@ | ||
|
||
serve: build | ||
docker run -it --rm -p 80:80 -v "$$PWD"/build/:/var/www/html/ php:8.1-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground" | ||
|
||
served: build | ||
docker run -d --rm -p 80:80 -v "$$PWD"/build/:/var/www/html/ php:8.1-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground" | ||
@sleep 2 | ||
@echo Container running. Use \"docker rm -f {containerId}\" to stop container. | ||
|
||
test: | ||
bash tests/acceptance.sh | ||
|
||
clean: | ||
rm -rf build/ vendor/ | ||
|
||
.PHONY: build serve served test clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,55 @@ | ||
# clue.engineering | ||
|
||
Source code for https://clue.engineering/ | ||
Source code for the https://clue.engineering/ website. | ||
|
||
## Install | ||
## Build | ||
|
||
Install dependencies: | ||
You can build the website like this: | ||
|
||
```bash | ||
composer install | ||
make | ||
``` | ||
|
||
Build website: | ||
Once built, you can manually browse the `build/` directory or run the web server | ||
container (Apache) in the foreground like this: | ||
|
||
```bash | ||
vendor/bin/sculpin generate | ||
make serve | ||
``` | ||
|
||
This will create a `build/` directory that contains the static website that can | ||
be accessed with a web browser. | ||
Alternatively, you may also run the web server container (Apache) as a | ||
background daemon like this: | ||
|
||
## Deploy | ||
|
||
Then deploy `build/` behind your favorite webserver (Apache + PHP-FPM etc.). | ||
|
||
Additionally, this should be deployed behind a reverse proxy (nginx) that is | ||
responsible for HTTPS certificate handling and forcing HTTPS redirects. | ||
|
||
Additionally, Apache has been configured to cache static files for 1 day. | ||
```bash | ||
make served | ||
``` | ||
|
||
For testing purposes, you can use the official `php` docker image like this: | ||
Once running, you can run some integration tests that check correct paths etc. | ||
like this: | ||
|
||
```bash | ||
docker run -it --rm -p 80:80 -v "$PWD"/build:/var/www/html php:8.1-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground" | ||
make test | ||
``` | ||
|
||
## Tests | ||
> This test assumes you're running the above web server container on | ||
> `http://clue.localhost`. You may test other deployments like this: | ||
> | ||
> ```bash | ||
> tests/acceptance.sh https://clue.example | ||
> ``` | ||
You can run some simple acceptance tests to verify the deployed website works | ||
as expected by running: | ||
Once done, you can clean up like this: | ||
```bash | ||
tests/acceptance.sh https://clue.test | ||
make clean | ||
``` | ||
If you're using the above `php` docker image, you can run this test like this: | ||
## Deploy | ||
|
||
```bash | ||
tests/acceptance.sh http://clue.localhost | ||
``` | ||
Once built (see previous "Build" section), you can simply deploy the `build/` | ||
directory behind your favorite web server (Apache + PHP-FPM etc.). | ||
|
||
Additionally, this should be deployed behind a reverse proxy (nginx) that is | ||
responsible for HTTPS certificate handling and forcing HTTPS redirects. | ||
|
||
Additionally, Apache has been configured to cache static files for 1 day. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters