Skip to content

Commit 26e8981

Browse files
committed
Add docker configuration files
Similar to cc/search repo
1 parent decd459 commit 26e8981

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

config/site.conf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<VirtualHost *:80>
2+
RewriteEngine On
3+
4+
# Set conservative/secure defaults
5+
<Directory />
6+
AllowOverride None
7+
DirectoryIndex index.html
8+
Options -Indexes
9+
</Directory>
10+
# Git
11+
<DirectoryMatch "/\.git">
12+
Require all denied
13+
</DirectoryMatch>
14+
# Subversion
15+
<DirectoryMatch "/\.svn">
16+
Require all denied
17+
</DirectoryMatch>
18+
# Deny access to accidental uploads of macOS-specific directories and files
19+
# .DS_Store
20+
<FilesMatch "^(\._)?\.[Dd][Ss]_[Ss]tore">
21+
Require all denied
22+
</FilesMatch>
23+
# resource forks
24+
<DirectoryMatch "/__MACOSX">
25+
Require all denied
26+
</DirectoryMatch>
27+
28+
DocumentRoot /usr/local/apache2/htdocs
29+
<Directory /usr/local/apache2/htdocs>
30+
# Also serve HTML files without .html extension
31+
RewriteCond %{REQUEST_FILENAME}.html -f
32+
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
33+
</Directory>
34+
35+
ErrorDocument 404 /404.html
36+
</VirtualHost>
37+
38+
# vim: ft=apache ts=4 sw=4 sts=4 sr noet

dev/node/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://docs.docker.com/engine/reference/builder/
2+
3+
# https://hub.docker.com/_/node
4+
FROM node:bookworm-slim
5+
6+
RUN npm install --global prettier

dev/web/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://docs.docker.com/engine/reference/builder/
2+
3+
# https://hub.docker.com/_/httpd
4+
FROM httpd:2.4
5+
6+
# Update Apache2 configuration
7+
8+
# Set ServerName to prevent warning
9+
RUN sed -e's/^#ServerName.*/ServerName static/' -i'' \
10+
/usr/local/apache2/conf/httpd.conf
11+
12+
# Enable mod_rewrite
13+
# https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
14+
RUN sed -e's/^#LoadModule rewrite/LoadModule rewrite/' -i'' \
15+
/usr/local/apache2/conf/httpd.conf
16+
17+
# Include site configuration
18+
RUN echo 'Include conf/config/site.conf' \
19+
| tee -a /usr/local/apache2/conf/httpd.conf

docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: chooser
2+
services:
3+
web:
4+
build:
5+
context: .
6+
dockerfile: dev/web/Dockerfile
7+
# Use Bash instad of sh (Dash) for improved signal handling
8+
command: /bin/bash -c "
9+
echo 'Starting static webserver at http://127.0.0.1:8080/';
10+
/usr/local/bin/httpd-foreground
11+
"
12+
container_name: cc-chooser-web
13+
ports:
14+
- "8080:80"
15+
restart: on-failure
16+
volumes:
17+
# Mount site configuration directory
18+
- "./config:/usr/local/apache2/conf/config:ro"
19+
# Mount website directory
20+
- "./src:/usr/local/apache2/htdocs:ro"
21+
22+
node:
23+
build:
24+
context: .
25+
dockerfile: dev/node/Dockerfile
26+
# Continue running until shutdown (this allows docker compose exec which is
27+
# much faster than docker compose run)
28+
# Thank you: https://serverfault.com/a/1084975
29+
command: /bin/sh -c "
30+
trap 'exit' TERM;
31+
echo 'Run the following command to format files with Prettier:';
32+
echo ' docker compose exec node prettier --write src/';
33+
while true; do sleep 1; done
34+
"
35+
container_name: cc-chooser-node
36+
volumes:
37+
# Mount repository to working directory
38+
- "./:/opt"
39+
working_dir: /opt

0 commit comments

Comments
 (0)