Skip to content

Commit 9fa129d

Browse files
Made it possible to change the port via the ENV Variable CWA_PORT_OVERRIDE. Default port is still 8083. External port now defaults to override port if given
1 parent 7aebf25 commit 9fa129d

File tree

11 files changed

+23
-16
lines changed

11 files changed

+23
-16
lines changed

CONTRIBUTORS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CONTRIBUTORS
22

33
This file is automatically generated. DO NOT EDIT MANUALLY.
4-
Generated on: 2025-08-25T17:44:28.444765Z
4+
Generated on: 2025-08-25T19:21:37.195194Z
55

66
Upstream project: https://github.com/janeczku/calibre-web
77
Fork project (Calibre-Web Automated, since 2024): https://github.com/crocodilestick/calibre-web-automated
@@ -289,7 +289,7 @@ Copyright (C) 2024-2025 Calibre-Web Automated contributors
289289
- zhiyue (1 commits)
290290
# Fork Contributors (crocodilestick/calibre-web-automated)
291291

292-
- crocodilestick (564 commits)
292+
- crocodilestick (567 commits)
293293
- jmarmstrong1207 (73 commits)
294294
- demitrix (30 commits)
295295
- sirwolfgang (22 commits)

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ ENV CALIBRE_CONFIG_DIR=/config/.config/calibre
191191

192192
# ports and volumes
193193
WORKDIR /config
194+
# The default port CWA listens on. Can be overridden with the CWA_PORT_OVERRIDE environment variable.
194195
EXPOSE 8083
195196
VOLUME /config
196197
VOLUME /cwa-book-ingest

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ services:
288288
# If your library is on a network share (e.g., NFS/SMB), disable WAL to reduce locking issues
289289
# Accepts: true/false (default: false)
290290
- NETWORK_SHARE_MODE=false
291+
# Override the default port (8083) for the web server.
292+
# Accepts any valid port number.
293+
- CWA_PORT_OVERRIDE=8083
291294
volumes:
292295
# CW users migrating should stop their existing CW instance, make a copy of the config folder, and bind that here to carry over all of their user settings ect.
293296
- /path/to/config/folder:/config

cps/admin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,6 @@ def _configuration_update_helper():
18121812
reboot_required = False
18131813
to_save = request.form.to_dict()
18141814
try:
1815-
reboot_required |= _config_int(to_save, "config_port")
18161815
reboot_required |= _config_string(to_save, "config_trustedhosts")
18171816
reboot_required |= _config_string(to_save, "config_keyfile")
18181817
if config.config_keyfile and not os.path.isfile(config.config_keyfile):

cps/config_sql.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class _Settings(_Base):
6262
config_calibre_uuid = Column(String)
6363
config_calibre_split = Column(Boolean, default=False)
6464
config_calibre_split_dir = Column(String)
65-
config_port = Column(Integer, default=constants.DEFAULT_PORT)
6665
config_external_port = Column(Integer, default=constants.DEFAULT_PORT)
6766
config_certfile = Column(String)
6867
config_keyfile = Column(String)

cps/constants.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@
127127

128128
DEFAULT_PASSWORD = "admin123" # nosec
129129
DEFAULT_PORT = 8083
130-
env_CALIBRE_PORT = os.environ.get("CALIBRE_PORT", DEFAULT_PORT)
131-
try:
132-
DEFAULT_PORT = int(env_CALIBRE_PORT)
133-
except ValueError:
134-
print('Environment variable CALIBRE_PORT has invalid value (%s), faling back to default (8083)' % env_CALIBRE_PORT)
135-
del env_CALIBRE_PORT
130+
env_CWA_PORT_OVERRIDE = os.environ.get("CWA_PORT_OVERRIDE")
131+
if env_CWA_PORT_OVERRIDE:
132+
try:
133+
DEFAULT_PORT = int(env_CWA_PORT_OVERRIDE)
134+
except (ValueError, TypeError):
135+
print(f"Environment variable CWA_PORT_OVERRIDE has invalid value ('{env_CWA_PORT_OVERRIDE}'), falling back to default (8083)")
136+
DEFAULT_PORT = 8083
136137

137138

138139
EXTENSIONS_AUDIO = {'mp3', 'mp4', 'ogg', 'opus', 'wav', 'flac', 'm4a', 'm4b'}

cps/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
VERSION = 'Tornado ' + _version
3131
_GEVENT = False
3232

33-
from . import logger
33+
from . import logger, constants
3434

3535

3636
log = logger.create()
@@ -60,7 +60,7 @@ def __init__(self):
6060
def init_app(self, application, config):
6161
self.app = application
6262
self.listen_address = config.get_config_ipaddress()
63-
self.listen_port = config.config_port
63+
self.listen_port = constants.DEFAULT_PORT
6464

6565
if config.config_access_log:
6666
log_name = "gevent.access" if _GEVENT else "tornado.access"

cps/templates/admin.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ <h2>{{_('Configuration&nbsp;&nbsp;⚙️')}}</h2>
118118
</div>
119119
<div class="row">
120120
<div class="col-xs-6 col-sm-6">{{_('Port')}}</div>
121-
<div class="col-xs-6 col-sm-6">{{config.config_port}}</div>
121+
<div class="col-xs-6 col-sm-6">{{config.config_external_port}}</div>
122122
</div>
123-
{% if kobo_support and config.config_port != config.config_external_port %}
123+
{% if kobo_support and config.config_external_port != config.config_external_port %}
124124
<div class="row">
125125
<div class="col-xs-6 col-sm-6">{{_('External Port')}}</div>
126126
<div class="col-xs-6 col-sm-6">{{config.config_external_port}}</div>

cps/templates/config_edit.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ <h4 class="panel-title">
2121
</div>
2222
<div id="collapseone" class="panel-collapse collapse">
2323
<div class="panel-body">
24-
<div class="form-group">
24+
<!-- <div class="form-group">
2525
<label for="config_port">{{_('Server Port')}}</label>
2626
<input type="number" min="1" max="65535" class="form-control" name="config_port" id="config_port" value="{% if config.config_port != None %}{{ config.config_port }}{% endif %}" autocomplete="off" required>
27-
</div>
27+
</div> -->
2828
<label for="config_certfile">{{_('SSL certfile location (leave it empty for non-SSL Servers)')}}</label>
2929
<div class="form-group input-group">
3030
<input type="text" class="form-control" id="config_certfile" name="config_certfile" value="{% if config.config_certfile != None %}{{ config.config_certfile }}{% endif %}" autocomplete="off">

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ services:
99
- PGID=1000
1010
# Edit to match your current timezone https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
1111
- TZ=UTC
12+
# Sets the listening port for the application. Defaults to 8083.
13+
# - CWA_PORT_OVERRIDE=8083
1214
# Hardcover API Key required for Hardcover as a Metadata Provider, get one here: https://docs.hardcover.app/api/getting-started/
1315
- HARDCOVER_TOKEN=your_hardcover_api_key_here
1416
# If your library is on a network share (e.g., NFS/SMB), disables WAL and chown to reduce locking/permission issues,

0 commit comments

Comments
 (0)