chore(#17): Adds Docker packaging to the project
This commit is contained in:
parent
38520c6e2a
commit
1887be54e5
4 changed files with 31 additions and 3 deletions
25
Dockerfile
Normal file
25
Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
|||
FROM node:23-alpine3.20 AS node
|
||||
|
||||
WORKDIR /shortenit
|
||||
COPY frontend /shortenit
|
||||
|
||||
RUN npm run build
|
||||
|
||||
FROM python:3.13-alpine3.21 AS python
|
||||
|
||||
WORKDIR /shortenit
|
||||
COPY . /shortenit
|
||||
COPY --from=node /ui/ /shorthenit/ui/
|
||||
|
||||
RUN rm -rf dist/ && \
|
||||
pip install poetry && \
|
||||
poetry build
|
||||
|
||||
FROM python:3.13-alpine3.21
|
||||
|
||||
COPY --from=python /shortenit/dist/*.tar.gz /shortenit/
|
||||
|
||||
RUN pip install /shortenit/*.tar.gz && \
|
||||
rm -rf /shortenit
|
||||
|
||||
ENTRYPOINT ["shortenit"]
|
|
@ -1,5 +1,6 @@
|
|||
Server:
|
||||
host: 127.0.0.1
|
||||
hostname: localhost
|
||||
bind_ip: 0.0.0.0
|
||||
port: 8000
|
||||
scheme: http
|
||||
cors: False
|
||||
|
|
|
@ -45,7 +45,7 @@ def main() -> typing.NoReturn:
|
|||
with Session(bind=engine, autoflush=True, future=True) as session:
|
||||
handler = SiteHandler(config, session, shorten_it, lengthen_it)
|
||||
web = Web(handler, debug=debug)
|
||||
web.host = server_config.get("host", None)
|
||||
web.host = server_config.get("bind_ip", None)
|
||||
web.port = server_config.get("port", None)
|
||||
web.start_up()
|
||||
|
||||
|
|
|
@ -63,13 +63,15 @@ class SiteHandler:
|
|||
return self.configuration.get("Server", None)
|
||||
|
||||
def _get_host(self):
|
||||
host = self._get_server_config()["host"]
|
||||
host = self._get_server_config()["hostname"]
|
||||
port = self._get_server_config()["port"]
|
||||
scheme = self._get_server_config()["scheme"]
|
||||
return scheme, host, port
|
||||
|
||||
def _get_url(self, stub):
|
||||
scheme, host, port = self._get_host()
|
||||
if (port == "443" and scheme == "https") or (port == "80" and scheme == "http"):
|
||||
return urlunparse((scheme, f"{host}", f"/r/{stub}", "", "", ""))
|
||||
return urlunparse((scheme, f"{host}:{port}", f"/r/{stub}", "", "", ""))
|
||||
|
||||
def shortenit(self):
|
||||
|
|
Loading…
Reference in a new issue