Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ jobs:
php-version: ${{ matrix.php }}
coverage: none
- run: make
- run: make served
- run: bash tests/await.bash http://clue.localhost/
- run: docker compose build
- run: docker compose up -d --wait
- run: make test
- run: docker compose stop -t 60
timeout-minutes: 0.5
- run: docker compose logs --timestamps | sort -k3
if: ${{ always() }}
- run: git config --global user.name "GitHub Actions" && git config --global user.email "actions@github.com"
- run: git config --global url."https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
- run: make deploy
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/vendor/
/build/
/tailwindcss
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1
FROM composer:2 AS composer
WORKDIR /app/
COPY composer.json composer.lock ./
RUN composer install --ignore-platform-reqs --optimize-autoloader

FROM scratch AS tailwind
WORKDIR /app/
ADD --checksum=sha256:cd52e757cb0bd15238f0207a215198d924811234028d056b7be39fde70491296 --chmod=0755 \
https://github.com/tailwindlabs/tailwindcss/releases/download/v3.2.4/tailwindcss-linux-x64 /usr/local/bin/tailwindcss
ENTRYPOINT ["tailwindcss"]

FROM php:8.1-apache AS build
WORKDIR /app/
COPY --from=composer /app/vendor/ vendor/
COPY app/ app/
COPY www/ www/
RUN vendor/bin/sculpin generate

FROM php:8.1-apache
RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled
COPY --from=build /app/build/ /var/www/html/
HEALTHCHECK --start-period=1m --start-interval=0.1s --interval=1h \
CMD ["curl", "-I", "--no-progress-meter", "http://localhost/"]
20 changes: 5 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ vendor: composer.json composer.lock
composer install
touch $@

www/src/tailwind.min.css: www/_layouts/* www/_posts/* www/_talks/* www/*.html www/*.html.twig tailwindcss tailwind.config.js
./tailwindcss -o $@ --minify
www/src/tailwind.min.css: www/_layouts/* www/_posts/* www/_talks/* www/*.html www/*.html.twig tailwind.config.js
docker compose run --rm --build tailwind -o $@ --minify
touch $@

tailwindcss:
test -x tailwindcss || curl -L https://github.com/tailwindlabs/tailwindcss/releases/download/v3.2.4/tailwindcss-linux-x64 > tailwindcss && chmod +x tailwindcss

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/integration.bash http://clue.localhost/
test -z "$$(git status --porcelain)" || (echo Directory is dirty && git status && exit 1)
Expand All @@ -33,6 +22,7 @@ deploy:
git -C build/ push origin live -f

clean:
rm -rf build/ vendor/ tailwindcss
rm -rf build/ vendor/
docker compose down --remove-orphans --rmi local

.PHONY: build serve served test deploy clean
.PHONY: build test deploy clean
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@

Source code for the https://clue.engineering/ website.

## Build
## Development

### Build

You can build the website like this:

```bash
make
```

### Run

Once built, you can manually browse the `build/` directory or run the web server
container (Apache) in the foreground like this:

```bash
make serve
docker compose up --build --watch
```

Alternatively, you may also run the web server container (Apache) as a
background daemon like this:
> Once running, you can now access http://clue.localhost/ in your web browser.
> If you want to run this on a different port, you may pass the `PORT`
> environment variable like `PORT=8080 docker compose up`.
> To run the container in the background, you may use the `docker compose up -d` command.

```bash
make served
```
### Tests

Once running, you can run some integration tests that check correct paths etc.
like this:
Expand All @@ -41,6 +45,8 @@ make test
> tests/integration.bash http://clue.localhost/
> ```

### Cleanup

Once done, you can clean up like this:

```bash
Expand Down
34 changes: 34 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
# main apache service running the full website
apache:
build: .
ports:
- ${PORT:-80}:80
restart: unless-stopped
develop:
watch:
- path: app/
action: rebuild
- path: www/
action: rebuild
- path: composer.lock
action: rebuild
- path: Dockerfile
action: rebuild

# tailwind dev sidecar to watch and recompile CSS on demand
tailwind:
build:
context: .
target: tailwind
command: --watch -o www/src/tailwind.min.css --minify
restart: unless-stopped
stdin_open: true
stop_signal: SIGKILL
volumes:
- ./tailwind.config.js:/app/tailwind.config.js:ro
- ./www:/app/www:rw
develop:
watch:
- path: Dockerfile
action: rebuild
16 changes: 0 additions & 16 deletions tests/await.bash

This file was deleted.