Skip to content

Commit

Permalink
Automatically use Docker volume for persisting SQLite DB and appsetti…
Browse files Browse the repository at this point in the history
…ngs.json.
  • Loading branch information
bitbound committed May 6, 2021
1 parent ae44296 commit f86e50b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
23 changes: 23 additions & 0 deletions Server/DockerMain.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 11 additions & 5 deletions Server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ EXPOSE 5000
ENV ASPNETCORE_ENVIRONMENT="Production"
ENV ASPNETCORE_URLS="http://*:5000"


RUN \
apt-get -y update && \
apt-get -y install \
Expand All @@ -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"]

0 comments on commit f86e50b

Please sign in to comment.