-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from rivenmedia/feat/docker-image
feat: add docker image
- Loading branch information
Showing
7 changed files
with
148 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Extras That Shouldn't Be Here | ||
.git/ | ||
.gitignore | ||
.dockerignore | ||
docker-compose* | ||
Dockerfile | ||
makefile | ||
htmlcov/ | ||
coverage.xml | ||
.coverage* | ||
|
||
.vscode/ | ||
.ruff_cache/ | ||
*.dat | ||
|
||
# Backend | ||
settings.json | ||
|
||
# frontend | ||
|
||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,4 @@ jobs: | |
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- run: pnpm lint | ||
- run: pnpm lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Frontend Builder | ||
FROM node:20-alpine AS frontend | ||
WORKDIR /app | ||
COPY . . | ||
RUN npm install -g pnpm && pnpm install | ||
RUN pnpm run build && pnpm prune --prod | ||
|
||
# Final Image | ||
FROM node:20-alpine | ||
LABEL name="Riven" \ | ||
description="Riven Media Server: Frontend" \ | ||
url="https://github.com/rivenmedia/riven-frontend" | ||
|
||
# Set working directory | ||
WORKDIR /riven | ||
|
||
# Copy frontend build from the previous stage | ||
COPY --from=frontend /app/build /riven/build | ||
COPY --from=frontend /app/node_modules /riven/node_modules | ||
COPY --from=frontend /app/package.json /riven/package.json | ||
|
||
COPY version.txt entrypoint.sh /riven/ | ||
|
||
# Ensure entrypoint script is executable | ||
RUN chmod +x /riven/entrypoint.sh | ||
|
||
ENTRYPOINT ["/riven/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/sh | ||
|
||
# Default PUID and PGID to 1000 if not set | ||
PUID=${PUID:-1001} | ||
PGID=${PGID:-1001} | ||
|
||
echo "Starting Container with $PUID:$PGID permissions..." | ||
|
||
if [ "$PUID" = "0" ]; then | ||
echo "Running as root user" | ||
USER_HOME="/root" | ||
mkdir -p "$USER_HOME" | ||
else | ||
# Validate PUID and PGID are integers | ||
if ! echo "$PUID" | grep -qE '^[0-9]+$'; then | ||
echo "PUID is not a valid integer. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
if ! echo "$PGID" | grep -qE '^[0-9]+$'; then | ||
echo "PGID is not a valid integer. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
# Default USERNAME and GROUPNAME if not set | ||
USERNAME=${USERNAME:-riven} | ||
GROUPNAME=${GROUPNAME:-riven} | ||
USER_HOME="/home/$USERNAME" | ||
|
||
# Create group if it doesn't exist | ||
if ! getent group "$PGID" > /dev/null; then | ||
addgroup -g "$PGID" "$GROUPNAME" | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to create group. Exiting..." | ||
exit 1 | ||
fi | ||
else | ||
GROUPNAME=$(getent group "$PGID" | cut -d: -f1) | ||
fi | ||
|
||
# Create user if it doesn't exist | ||
if ! getent passwd "$USERNAME" > /dev/null; then | ||
if getent passwd "$PUID" > /dev/null; then | ||
EXISTING_USER=$(getent passwd "$PUID" | cut -d: -f1) | ||
if [ "$EXISTING_USER" != "$USERNAME" ]; then | ||
echo "UID $PUID is already in use by $EXISTING_USER. Please choose a different UID." | ||
exit 1 | ||
else | ||
echo "User $USERNAME already exists with UID $PUID." | ||
fi | ||
else | ||
adduser -D -h "$USER_HOME" -u "$PUID" -G "$GROUPNAME" "$USERNAME" | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to create user. Exiting..." | ||
exit 1 | ||
fi | ||
fi | ||
else | ||
if [ "$PUID" -ne 0 ]; then | ||
echo "User modification not supported in this script for Alpine. Please ensure correct PUID/PGID beforehand." | ||
fi | ||
fi | ||
|
||
mkdir -p "$USER_HOME" | ||
chown -R "$PUID:$PGID" "$USER_HOME" | ||
fi | ||
|
||
umask 002 | ||
|
||
export XDG_CONFIG_HOME="$USER_HOME/.config" | ||
export XDG_DATA_HOME="$USER_HOME/.local/share" | ||
export HOME="$USER_HOME" | ||
|
||
: ${ORIGIN:="http://localhost:3000"} | ||
: ${BACKEND_URL:="http://127.0.0.1"} | ||
|
||
# Start the frontend | ||
echo "Starting frontend..." | ||
exec su -m $USERNAME -c "ORIGIN=$ORIGIN BACKEND_URL=$BACKEND_URL node /riven/build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters