Concise Dockerfile and entrypoint

This commit is contained in:
Grzegorz Gidel
2023-04-30 16:23:36 +02:00
parent a772cf5aee
commit ebe1ee20d1
2 changed files with 15 additions and 34 deletions

View File

@ -23,18 +23,14 @@ COPY . ./
# Copy default chats, characters and user avatars to <folder>.default folder
RUN \
echo "*** Copy default chats, characters and user avatars to <folder>.default folder ***" && \
mv "./public/characters" "./public/characters.default" && \
mv "./public/chats" "./public/chats.default" && \
mv "./public/User Avatars" "./public/User Avatars.default" && \
mv "./public/settings.json" "./public/settings.json.default" && \
IFS="," RESOURCES="characters,chats,User Avatars,settings.json" && \
\
echo "*** Store default $RESOURCES in <folder>.default ***" && \
for R in $RESOURCES; do mv "public/$R" "public/$R.default"; done && \
\
echo "*** Create symbolic links to config directory ***" && \
ln -s "${APP_HOME}/config/characters" "${APP_HOME}/public/characters" && \
ln -s "${APP_HOME}/config/chats" "${APP_HOME}/public/chats" && \
ln -s "${APP_HOME}/config/User Avatars" "${APP_HOME}/public/User Avatars" && \
ln -s "${APP_HOME}/config/settings.json" "${APP_HOME}/public/settings.json" && \
mkdir "${APP_HOME}/config"
for R in $RESOURCES; do ln -s "../config/$R" "public/$R"; done && \
mkdir "config"
# Cleanup unnecessary files
RUN \

View File

@ -1,28 +1,13 @@
#!/bin/sh
# Check if the "characters" directory is empty
if [ ! -e "/home/node/app/config/characters" ]; then
echo "Characters directory not found. Copying default characters."
mv /home/node/app/public/characters.default /home/node/app/config/characters
fi
# Check if the "chats" directory is empty
if [ ! -e "/home/node/app/config/chats" ]; then
echo "Chats directory not found. Copying default chats."
mv /home/node/app/public/chats.default /home/node/app/config/chats/
fi
# Check if the "User Avatars" directory is empty
if [ ! -e "/home/node/app/config/User Avatars" ]; then
echo "User Avatars directory not found. Copying default user avatars."
mv /home/node/app/public/User\ Avatars.default /home/node/app/config/User\ Avatars/
fi
# Check if the "settings.json" file is not empty
if [ ! -e "/home/node/app/config/settings.json" ]; then
echo "Settings file not found. Copying default settings."
mv /home/node/app/public/settings.json.default /home/node/app/config/settings.json
# Initialize missing user files
IFS="," RESOURCES="characters,chats,User Avatars,settings.json"
for R in $RESOURCES; do
if [ ! -e "config/$R" ]; then
echo "Resource not found, copying from defaults: $R"
cp -r "public/$R.default" "config/$R"
fi
done
# Start the server
exec node /home/node/app/server.js
exec node server.js