add: frontend docker deploy scripts

main
w2 4 years ago
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

@ -3,8 +3,30 @@ version: "2"
services:
backend:
image: photovoter-backend:latest
ports:
- "8000:8000"
volumes:
- ./photovoter_data:/srv/photovoter
networks:
default:
aliases:
- backend
frontend:
image: photovoter-frontend:latest
ports:
- "80:80"
volumes:
- ./photovoter_data/image:/srv/photos
- caddy_data:/data
- caddy_config:/config
networks:
- default
volumes:
caddy_data:
external: true
caddy_config:
networks:
default:

Loading…
Cancel
Save