Skip to content

Commit 0397733

Browse files
author
André Felipe Dias
committed
api server (hypercorn) do not use ssl certifications anymore. Caddy will provide https access instead
1 parent 398b290 commit 0397733

20 files changed

+8
-199
lines changed

backend/Dockerfile.fastapi_api

-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ ENV PATH=/venv/bin:${PATH}
3434
WORKDIR /backend/fastapi_api
3535
RUN chown -R nobody:nogroup .
3636
COPY --chown=nobody:nogroup fastapi_api/app ./app
37-
COPY --chown=nobody:nogroup fastapi_api/cert ./cert
3837
COPY --chown=nobody:nogroup fastapi_api/hypercorn.toml .
3938
COPY --chown=nobody:nogroup common/app /backend/common/app
40-
COPY --chown=nobody:nogroup common/cert /backend/common/cert
4139

4240
USER nobody
4341

backend/Dockerfile.quart_api

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ ENV PATH=/venv/bin:${PATH}
3232
WORKDIR /backend/quart_api
3333
RUN chown -R nobody:nogroup .
3434
COPY --chown=nobody:nogroup quart_api/app ./app
35-
COPY --chown=nobody:nogroup common/cert ./cert
3635
COPY --chown=nobody:nogroup quart_api/hypercorn.toml .
3736

3837
USER nobody

backend/Dockerfile.tornado_api

-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ ENV PATH=/venv/bin:${PATH}
3333
WORKDIR /backend/tornado_api
3434
RUN chown -R nobody:nogroup .
3535
COPY --chown=nobody:nogroup tornado_api/app ./app
36-
COPY --chown=nobody:nogroup tornado_api/cert ./cert
3736
COPY --chown=nobody:nogroup common/app /backend/common/app
38-
COPY --chown=nobody:nogroup common/cert /backend/common/cert
3937

4038
USER nobody
4139

backend/common/app/resources.py

-1
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,3 @@ def migrate_database():
142142
alembic_cfg.set_main_option('script_location', str(root_dir / 'alembic'))
143143
upgrade(alembic_cfg, 'head')
144144
return
145-

backend/common/cert/README.rst

-3
This file was deleted.

backend/common/cert/server.key

-28
This file was deleted.

backend/common/cert/server.pem

-19
This file was deleted.

backend/common/docker-compose.yml

-28
This file was deleted.

backend/fastapi_api/cert

-1
This file was deleted.

backend/fastapi_api/hypercorn.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
worker_class = "uvloop"
2-
bind = "0.0.0.0:8443"
3-
certfile = "cert/server.pem"
4-
keyfile = "cert/server.key"
2+
bind = "0.0.0.0:8000"
53
accesslog = "-"
64
errorlog = "-"
75
access_log_format = "%(t)s %(h)s %(S)s %(r)s %(s)s"

backend/quart_api/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ ENV PATH=/venv/bin:${PATH}
2727
WORKDIR /app
2828
RUN chown -R nobody:nogroup /app
2929
COPY --chown=nobody:nogroup app /app
30-
COPY --chown=nobody:nogroup cert /app/cert
3130
COPY --chown=nobody:nogroup hypercorn.toml .
3231

3332
USER nobody

backend/quart_api/cert/README.rst

-3
This file was deleted.

backend/quart_api/cert/server.key

-28
This file was deleted.

backend/quart_api/cert/server.pem

-19
This file was deleted.

backend/quart_api/hypercorn.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
worker_class = "uvloop"
2-
bind = "0.0.0.0:8443"
3-
certfile = "cert/server.pem"
4-
keyfile = "cert/server.key"
2+
bind = "0.0.0.0:8000"
53
accesslog = "-"
64
errorlog = "-"
75
access_log_format = "%(t)s %(h)s %(S)s %(r)s %(s)s"

backend/tornado_api/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
ENV=development python -m app.main
2+
python -m app.main .env
33

44

55
test:

backend/tornado_api/app/main.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ def create_app(env_filename: Union[str, Path] = None) -> Iterator[Application]:
4242

4343

4444
if __name__ == '__main__':
45-
import ssl
45+
import sys
4646

47-
with create_app() as app:
48-
port = 8443
49-
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
50-
ssl_ctx.load_cert_chain('cert/server.pem', 'cert/server.key')
51-
http_server = HTTPServer(app, ssl_options=ssl_ctx)
47+
env_filename = '' if len(sys.argv) == 1 else sys.argv[1]
48+
with create_app(env_filename) as app:
49+
port = 8000
50+
http_server = HTTPServer(app)
5251
http_server.listen(port)
5352
logger.info(f'Listening to port {port} over https (use CTRL + C to quit)')
5453
IOLoop.current().start()

backend/tornado_api/cert/README.rst

-3
This file was deleted.

backend/tornado_api/cert/server.key

-28
This file was deleted.

backend/tornado_api/cert/server.pem

-19
This file was deleted.

0 commit comments

Comments
 (0)