mirror of
https://github.com/Pagwin-Fedora/website.git
synced 2025-07-17 22:55:42 +00:00
successful containerization just need to add the UI for comments now
This commit is contained in:
parent
5deea869e4
commit
4aadacac1e
3 changed files with 28 additions and 5 deletions
11
Dockerfile
11
Dockerfile
|
@ -1,7 +1,7 @@
|
|||
FROM alpine:3.18 as build
|
||||
# making my own image for hugo because there doesn't seem to be an official one in repo, lazy so we're going with alpine
|
||||
RUN ["apk", "update"]
|
||||
RUN ["apk", "add hugo"]
|
||||
RUN ["apk", "add", "hugo"]
|
||||
ADD . /root/
|
||||
WORKDIR /root
|
||||
# pass in the uri or ip of the comments api so nginx can forward to it
|
||||
|
@ -10,7 +10,8 @@ ENV COMMENTS_BACKEND=${WITH_BACKEND}
|
|||
RUN ["hugo", "--minify"]
|
||||
|
||||
FROM python:3.11-alpine as fiddling
|
||||
RUN ["adduser", "-h", "/application", "application"]
|
||||
RUN ["mkdir", "/application"]
|
||||
RUN ["adduser", "-D", "-h", "/application", "application"]
|
||||
# might need to chown these
|
||||
ADD ./scripts/template_convert.py /application/template_convert.py
|
||||
ADD ./nginx.conf.template /application/nginx.conf.template
|
||||
|
@ -18,6 +19,6 @@ WORKDIR /application
|
|||
USER application
|
||||
RUN ["python", "/application/template_convert.py"]
|
||||
|
||||
FROM nginx:1.25
|
||||
COPY --from=fiddling /application/nginx.conf
|
||||
RUN
|
||||
FROM nginx:1.25-alpine
|
||||
COPY --from=fiddling /application/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build /root/public /usr/share/nginx/html
|
||||
|
|
|
@ -24,4 +24,6 @@ http {
|
|||
# we're going to use a python program to substitute this out
|
||||
proxy_pass http://${{COMMENTS_BACKEND}}
|
||||
}
|
||||
###---}
|
||||
}
|
||||
}
|
||||
|
|
20
scripts/template_convert.py
Normal file → Executable file
20
scripts/template_convert.py
Normal file → Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
var_name = "COMMENTS_BACKEND"
|
||||
file_name = "nginx.conf"
|
||||
back = os.environ.get(var_name)
|
||||
buf = str()
|
||||
with open(file_name+".template") as file:
|
||||
buf = file.read()
|
||||
|
||||
if back == None:
|
||||
buf = re.sub("###{---(.|\n)*###---}", "", buf)
|
||||
else:
|
||||
# ${{\s*$var_name\s*}}
|
||||
buf = re.sub(rf"\${{{{\s*{var_name}\s*}}}}",var_name,buf)
|
||||
|
||||
with open(file_name, "w+") as file:
|
||||
file.write(buf)
|
Loading…
Reference in a new issue