Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

need help with custom docker and dockerfile

Featured Replies

I am trying to host a discord bot that I am putting together which I have hosted on a private github repo being pushed to docker hub to install as a container on my unraid server.

Issue is, it for some reason isn't updating the installed dependencies when I add a new one to my requirements.txt

I am a huge novice when it comes to docker and was hoping someone can shed some light on what im doing wrong?

Here is my dockerfile omitting private info

# Use an official Python runtime as a parent image

FROM python:3.10-slim

# Install git and upgrade pip

RUN apt-get update && \

apt-get install -y git && \

pip install --upgrade pip && \

rm -rf /var/lib/apt/lists/*

# Set the working directory

WORKDIR /app

# Copy the entrypoint script into the container

COPY docker-entrypoint.sh /app/docker-entrypoint.sh

# Make the entrypoint script executable

RUN chmod +x /app/docker-entrypoint.sh

# Set the entrypoint

ENTRYPOINT ["/app/docker-entrypoint.sh"]

# Default command

CMD []

and here is my docker-entrypoint.sh file

set -e

TARGET_BRANCH=${GIT_BRANCH:-main}

APP_DIR="/app"

GIT_SOURCE_DIR="/app_source_repo"

if [ -z "$GITHUB_TOKEN" ]; then echo "Error: GITHUB_TOKEN not set."; exit 1; fi

if [ -z "$GIT_REPO_URL" ]; then echo "Error: GIT_REPO_URL not set."; exit 1; fi

echo "Ensuring git repository ($GIT_REPO_URL, branch $TARGET_BRANCH) is up to date in $GIT_SOURCE_DIR..."

AUTH_GIT_REPO_URL=$(echo "$GIT_REPO_URL" | sed "s|https://|https://x-access-token:${GITHUB_TOKEN}@|")

if [ -d "$GIT_SOURCE_DIR/.git" ]; then

echo "Existing repository found in $GIT_SOURCE_DIR. Attempting to update..."

cd "$GIT_SOURCE_DIR"

git config http.sslVerify true

git config pull.rebase false

current_branch=$(git rev-parse --abbrev-ref HEAD)

if [ "$current_branch" != "$TARGET_BRANCH" ]; then

echo "Current branch is $current_branch, switching to $TARGET_BRANCH..."

git checkout "$TARGET_BRANCH" || git checkout -b "$TARGET_BRANCH" origin/"$TARGET_BRANCH"

fi

git fetch origin "$TARGET_BRANCH"

echo "Resetting to origin/$TARGET_BRANCH..."

git reset --hard "origin/$TARGET_BRANCH"

echo "Cleaning repository..."

git clean -fdx

cd "$APP_DIR"

echo "Repository updated."

else

echo "No existing repository found. Cloning fresh into $GIT_SOURCE_DIR..."

rm -rf "$GIT_SOURCE_DIR"

git clone --branch "$TARGET_BRANCH" --single-branch "$AUTH_GIT_REPO_URL" "$GIT_SOURCE_DIR"

echo "Repository cloned."

fi

echo "Copying necessary files from $GIT_SOURCE_DIR to $APP_DIR..."

mkdir -p "$APP_DIR/src"

rm -rf "$APP_DIR/src"/* "$APP_DIR/requirements.txt"

if [ -d "$GIT_SOURCE_DIR/src" ]; then

cp -R "$GIT_SOURCE_DIR/src/." "$APP_DIR/src/"

echo "Copied src/ directory."

else

echo "Error: src/ directory not found in repository at $GIT_SOURCE_DIR/src."

exit 1

fi

if [ -f "$GIT_SOURCE_DIR/requirements.txt" ]; then

cp "$GIT_SOURCE_DIR/requirements.txt" "$APP_DIR/requirements.txt"

echo "Copied requirements.txt."

else

echo "Error: requirements.txt not found in repository at $GIT_SOURCE_DIR/requirements.txt."

exit 1

fi

echo "Necessary files copied to $APP_DIR."

echo "Installing/Updating Python dependencies from $APP_DIR/requirements.txt..."

pip install --no-cache-dir -r "$APP_DIR/requirements.txt"

cd "$APP_DIR/src"

echo "Starting bot from $APP_DIR/src/bot.py..."

exec python bot.py "$@"

Any help would be much appreciated!

docker-entrypoint.sh Dockerfile

Edited by Abhi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.