-
-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New live demo with Apache proxying, refs #1522
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM python:3-alpine | ||
|
||
RUN apk add --no-cache \ | ||
apache2 \ | ||
apache2-proxy \ | ||
bash | ||
|
||
RUN pip install datasette | ||
|
||
ENV TINI_VERSION v0.18.0 | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini | ||
RUN chmod +x /tini | ||
|
||
# Append this to the end of the default httpd.conf file | ||
RUN echo $'ServerName localhost\n\ | ||
\n\ | ||
<Proxy *>\n\ | ||
Order deny,allow\n\ | ||
Allow from all\n\ | ||
</Proxy>\n\ | ||
\n\ | ||
ProxyPass /prefix/ http://localhost:8001/\n\ | ||
Header add X-Proxied-By "Apache2"' >> /etc/apache2/httpd.conf | ||
|
||
RUN echo $'<a href="/prefix/">Datasette</a>' > /var/www/localhost/htdocs/index.html | ||
|
||
WORKDIR /app | ||
|
||
ADD https://latest.datasette.io/fixtures.db /app/fixtures.db | ||
|
||
RUN echo $'#!/usr/bin/env bash\n\ | ||
set -e\n\ | ||
\n\ | ||
httpd -D FOREGROUND &\n\ | ||
datasette fixtures.db --setting base_url "/prefix/" -h 0.0.0.0 -p 8001 &\n\ | ||
\n\ | ||
wait -n' > /app/start.sh | ||
|
||
RUN chmod +x /app/start.sh | ||
|
||
EXPOSE 80 | ||
ENTRYPOINT ["/tini", "--", "/app/start.sh"] |
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,5 @@ | ||
# Datasette running behind an Apache proxy | ||
|
||
See also [Running Datasette behind a proxy](https://docs.datasette.io/en/latest/deploying.html#running-datasette-behind-a-proxy) | ||
|
||
This live demo is running at https://apache-proxy-demo.datasette.io/ |
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,13 @@ | ||
#!/bin/bash | ||
# https://til.simonwillison.net/cloudrun/ship-dockerfile-to-cloud-run | ||
|
||
NAME="datasette-apache-proxy-demo" | ||
PROJECT=$(gcloud config get-value project) | ||
IMAGE="gcr.io/$PROJECT/$NAME" | ||
|
||
gcloud builds submit --tag $IMAGE | ||
gcloud run deploy \ | ||
--allow-unauthenticated \ | ||
--platform=managed \ | ||
--image $IMAGE $NAME \ | ||
--port 80 |