Fix container startup with mounted config
This commit is contained in:
+1
-2
@@ -4,5 +4,4 @@ Dockerfile
|
|||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
.env
|
.env
|
||||||
*.exe
|
*.exe
|
||||||
!config/
|
config/
|
||||||
!config/*.json
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
*.sh text eol=lf
|
||||||
+2
-3
@@ -18,11 +18,10 @@ WORKDIR /app
|
|||||||
# Copy binary and static front-end assets
|
# Copy binary and static front-end assets
|
||||||
COPY --from=builder /app/server /app/server
|
COPY --from=builder /app/server /app/server
|
||||||
COPY --from=builder /app/public /app/public
|
COPY --from=builder /app/public /app/public
|
||||||
COPY --from=builder /app/config /app/config.default
|
|
||||||
COPY start.sh /app/start.sh
|
COPY start.sh /app/start.sh
|
||||||
|
|
||||||
RUN chmod +x /app/start.sh
|
RUN mkdir -p /app/config && chmod +x /app/start.sh
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
ENTRYPOINT ["/app/start.sh"]
|
ENTRYPOINT ["/bin/sh", "/app/start.sh"]
|
||||||
|
|||||||
@@ -5,16 +5,19 @@ config_dir="/app/config"
|
|||||||
settings_file="$config_dir/appsettings.json"
|
settings_file="$config_dir/appsettings.json"
|
||||||
|
|
||||||
if [ ! -f "$settings_file" ]; then
|
if [ ! -f "$settings_file" ]; then
|
||||||
mkdir -p "$config_dir"
|
echo "Missing mounted config file: $settings_file" >&2
|
||||||
cp /app/config.default/appsettings.json "$settings_file"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
activities_file="$config_dir/activities.json"
|
activities_file="$config_dir/activities.json"
|
||||||
available_dates_file="$config_dir/dates_available.json"
|
available_dates_file="$config_dir/dates_available.json"
|
||||||
booked_dates_file="$config_dir/dates_booked.json"
|
booked_dates_file="$config_dir/dates_booked.json"
|
||||||
|
|
||||||
if [ ! -f "$activities_file" ] && ! grep -q '"activities"' "$settings_file"; then cp /app/config.default/activities.json "$activities_file"; fi
|
for config_file in "$activities_file" "$available_dates_file" "$booked_dates_file"; do
|
||||||
if [ ! -f "$available_dates_file" ] && ! grep -q '"availableDates"' "$settings_file"; then cp /app/config.default/dates_available.json "$available_dates_file"; fi
|
if [ ! -f "$config_file" ]; then
|
||||||
if [ ! -f "$booked_dates_file" ] && [ ! -f "$config_dir/booked_dates.json" ]; then cp /app/config.default/dates_booked.json "$booked_dates_file"; fi
|
echo "Missing mounted config file: $config_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
exec /app/server
|
exec /app/server
|
||||||
Reference in New Issue
Block a user