parent
10f92c938e
commit
c6eda0ebff
@ -0,0 +1,39 @@
|
||||
FROM caddy:2-alpine
|
||||
|
||||
ARG DOMAIN='gman.me'
|
||||
|
||||
# Prepair utils
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Pull frontend
|
||||
RUN git clone --depth=1 https://git.iamonlyherefortheicecream.ml/g/photovoter-front.git /srv && \
|
||||
rm -rf /srv/.git /srv/.gitignore
|
||||
|
||||
# Clean up
|
||||
RUN apk del git
|
||||
|
||||
# Configure domain
|
||||
RUN sed --in-place \
|
||||
--expression "s#http://127.0.0.1:8000#http://$DOMAIN/api/v1#g" \
|
||||
--expression "s#http://127.0.0.1:\${serverPort}#http://$DOMAIN/api/v1#g" \
|
||||
--expression "s#http://127.0.0.1:5500#http://$DOMAIN/photos#g" \
|
||||
/srv/app.js
|
||||
|
||||
# Configure caddy
|
||||
# follow https://github.com/tiangolo/fastapi/issues/102
|
||||
# to fix openapi.json hardcode ugliness
|
||||
RUN echo -e \
|
||||
"$DOMAIN {\n" \
|
||||
" root * /srv\n" \
|
||||
" file_server\n" \
|
||||
"\n" \
|
||||
" handle_path /api/v1/* {\n" \
|
||||
" rewrite * {path}\n" \
|
||||
" reverse_proxy backend:8000\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" redir /openapi.json /api/v1/openapi.json permanent\n" \
|
||||
"}" \
|
||||
> /etc/caddy/Caddyfile
|
||||
|
||||
ONBUILD RUN caddy validate
|
||||
Loading…
Reference in new issue