Automatically use Docker volume for persisting SQLite DB and appsettings.json.

This commit is contained in:
Jared Goodwin 2021-05-05 22:40:19 -07:00
parent 20469a16aa
commit 2d104a579b
2 changed files with 34 additions and 5 deletions

23
Server/DockerMain.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
echo "Entered main script."
ServerDir=/var/www/remotely
RemotelyData=/remotely-data
AppSettingsVolume=/remotely-data/appsettings.json
AppSettingsWww=/var/www/remotely/appsettings.json
if [ ! -f "$AppSettingsVolume" ]; then
echo "Copying appsettings.json to volume."
cp "$AppSettingsWww" "$AppSettingsVolume"
fi
if [ -f "$AppSettingsWww" ]; then
rm "$AppSettingsWww"
fi
ln -s "$AppSettingsVolume" "$AppSettingsWww"
echo "Starting Remotely server."
exec /usr/bin/dotnet /var/www/remotely/Remotely_Server.dll

View File

@ -5,7 +5,6 @@ EXPOSE 5000
ENV ASPNETCORE_ENVIRONMENT="Production"
ENV ASPNETCORE_URLS="http://*:5000"
RUN \
apt-get -y update && \
apt-get -y install \
@ -27,9 +26,16 @@ RUN \
mkdir /config && \
wget -q https://github.com/lucent-sea/Remotely/releases/latest/download/Remotely_Server_Linux-x64.zip && \
unzip -o Remotely_Server_Linux-x64.zip -d /var/www/remotely && \
rm Remotely_Server_Linux-x64.zip && \
setfacl -R -m u:www-data:rwx /var/www/remotely && \
chown -R www-data:www-data /var/www/remotely
rm Remotely_Server_Linux-x64.zip
RUN \
mkdir -p /remotely-data && \
sed -i 's/DataSource=Remotely.db/DataSource=\/remotely-data\/Remotely.db/' /var/www/remotely/appsettings.json
VOLUME "/remotely-data"
WORKDIR /var/www/remotely
ENTRYPOINT ["/usr/bin/dotnet", "/var/www/remotely/Remotely_Server.dll"]
COPY DockerMain.sh /
ENTRYPOINT ["/DockerMain.sh"]