Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@
!README.md
!LICENSE
!docker/entrypoints/entrypoint*.sh
!docker/entrypoints/common.sh
27 changes: 27 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ COPY ./backend/launch_redis_workers.py /repo/backend/

RUN uv sync

# Extract version from pyproject.toml
RUN mkdir -p /version
RUN python -c "import tomllib; print(tomllib.load(open('/repo/backend/pyproject.toml', 'rb'))['project']['version'])" > /version/backend.txt

# ------------------------------------------------------------------------------------ #
# Development #
# ------------------------------------------------------------------------------------ #
Expand All @@ -75,6 +79,19 @@ RUN --mount=type=cache,target=/var/cache/apk \
RUN npm install -g pnpm
RUN pnpm config set store-dir /repo/frontend/.pnpm-store

# Copy the lock files and install dependencies
WORKDIR /repo
COPY ./frontend/package.json /repo/frontend/
COPY ./frontend/pnpm-lock.yaml /repo/frontend/

WORKDIR /repo/frontend
RUN pnpm i

# Extract version from package.json
RUN mkdir -p /version
RUN python -c "import json; print(json.load(open('/repo/frontend/package.json'))['version'])" \
> /version/frontend.txt

ENV IB_SERVER_CONFIG="dev_docker"

# relies on mounting this volume
Expand Down Expand Up @@ -113,12 +130,20 @@ WORKDIR /repo
COPY ./frontend ./frontend/
RUN chown -R beetle:beetle /repo

# Extract version from package.json
RUN mkdir -p /version
RUN python -c "import json; print(json.load(open('/repo/frontend/package.json'))['version'])" \
> /version/frontend.txt

USER beetle
WORKDIR /repo/frontend
# RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
RUN pnpm install
RUN pnpm run build




# ------------------------------------------------------------------------------------ #
# Production #
# ------------------------------------------------------------------------------------ #
Expand All @@ -129,9 +154,11 @@ ENV IB_SERVER_CONFIG="prod"

WORKDIR /repo
COPY --from=build /repo/frontend/dist /repo/frontend/dist
COPY --from=build /version /version
COPY docker/entrypoints/entrypoint.sh .
COPY docker/entrypoints/entrypoint_user_scripts.sh .
COPY docker/entrypoints/entrypoint_fix_permissions.sh .
COPY docker/entrypoints/common.sh .
RUN chown -R beetle:beetle /repo

USER root
Expand Down
38 changes: 38 additions & 0 deletions docker/entrypoints/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# A number of common functions used by entrypoints

log() {
echo -e "[Entrypoint] $1"
}

log_error() {
echo -e "\033[0;31m[Entrypoint] $1\033[0m"
}

log_current_user() {
log "Running as '$(whoami)' with UID $(id -u) and GID $(id -g)"
log "Current working directory: $(pwd)"
}

log_version_info() {
log "Version info:"
log " Backend: $BACKEND_VERSION"
log " Frontend: $FRONTEND_VERSION"
log " Mode: $IB_SERVER_CONFIG"
}

get_version_info() {
if [ -f /version/backend.txt ]; then
export BACKEND_VERSION=$(cat /version/backend.txt)
else
export BACKEND_VERSION="unk"
fi

if [ -f /version/frontend.txt ]; then
export FRONTEND_VERSION=$(cat /version/frontend.txt)
else
export FRONTEND_VERSION="unk"
fi
}

# Populate the environment variables for the version info
get_version_info
20 changes: 14 additions & 6 deletions docker/entrypoints/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

#!/bin/sh
source ./common.sh

echo "Running as"
id
log_current_user
log_version_info

cd /repo

Expand All @@ -13,17 +15,23 @@ mkdir -p /config/beets-flask
# start backend #
# ------------------------------------------------------------------------------------ #

# Ignore warnings for production builds
export PYTHONWARNINGS="ignore"

# running the server from inside the backend dir makes imports and redis easier
cd /repo/backend

redis-server --daemonize yes
redis-server --daemonize yes >/dev/null 2>&1

python ./launch_redis_workers.py
python ./launch_redis_workers.py > /logs/redis_workers.log 2>&1

redis-cli FLUSHALL
redis-cli FLUSHALL >/dev/null 2>&1

# we need to run with one worker for socketio to work
uvicorn beets_flask.server.app:create_app --port 5001 \
--host 0.0.0.0 \
--factory \
--workers 4
--workers 4 \
--use-colors \
--log-level info \
--no-access-log
7 changes: 4 additions & 3 deletions docker/entrypoints/entrypoint_dev.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/sh
source ./docker/entrypoints/common.sh

whoami
id
pwd
log_current_user
log_version_info
log "Starting development environment..."

cd /repo/frontend

Expand Down
3 changes: 1 addition & 2 deletions docker/entrypoints/entrypoint_fix_permissions.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/sh

if [ ! -z "$USER_ID" ] && [ ! -z "$GROUP_ID" ]; then
echo "Updating UID to $USER_ID and GID to $GROUP_ID"
groupmod -g $GROUP_ID beetle
usermod -u $USER_ID -g $GROUP_ID beetle
usermod -u $USER_ID -g $GROUP_ID beetle > /dev/null 2>&1
chown -R beetle:beetle /home/beetle
chown -R beetle:beetle /repo
fi
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frontend",
"private": true,
"version": "0.1.0",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite --host --cors",
Expand Down Expand Up @@ -37,6 +37,7 @@
"@tanstack/eslint-plugin-query": "^5.78.0",
"@tanstack/router-vite-plugin": "^1.120.13",
"@types/diff": "^5.2.3",
"@types/node": "^24.0.0",
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.7",
"@types/react-window": "^1.8.8",
Expand Down
54 changes: 35 additions & 19 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion frontend/src/routes/_frontpage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ function Hero() {

function Footer() {
const theme = useTheme();

let versionString = `v${__FRONTEND_VERSION__}`;
if (__MODE__ !== "production") {
// Append the mode to the version string if not in production
versionString += ` (${__MODE__})`;
}

return (
<Box
sx={(theme) => ({
Expand Down Expand Up @@ -179,7 +186,7 @@ function Footer() {
variant="caption"
sx={{ color: "grey.700", mr: "auto", alignSelf: "flex-end" }}
>
&copy; 2025 P. Spitzner &amp; S. Mohr
{versionString} &copy; 2025 P. Spitzner &amp; S. Mohr
</Typography>

<Link
Expand Down
Loading
Loading