mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-05 18:48:41 +00:00
fix: add docker entrypoint sccript
This commit is contained in:
@@ -8,9 +8,13 @@ RUN dotnet publish SharpbinV3.Server.csproj -c Release -o /app/out
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/out .
|
COPY --from=build /app/out .
|
||||||
|
COPY SharpbinV3.Server/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||||
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
|
||||||
RUN useradd --create-home --uid 10001 appuser && mkdir -p /app/data && chown -R appuser:appuser /app
|
RUN useradd --create-home --uid 10001 appuser \
|
||||||
|
&& mkdir -p /app/data \
|
||||||
|
&& chown -R appuser:appuser /app \
|
||||||
|
&& chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
ENV ASPNETCORE_URLS=http://+:8080
|
ENV ASPNETCORE_URLS=http://+:8080
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
USER appuser
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
ENTRYPOINT ["dotnet", "SharpbinV3.Server.dll"]
|
CMD ["dotnet", "SharpbinV3.Server.dll"]
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
APP_USER="${APP_USER:-appuser}"
|
||||||
|
APP_GROUP="${APP_GROUP:-appuser}"
|
||||||
|
|
||||||
|
fix_path_owner() {
|
||||||
|
target="$1"
|
||||||
|
|
||||||
|
if [ -z "$target" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$target"
|
||||||
|
chown -R "$APP_USER:$APP_GROUP" "$target"
|
||||||
|
}
|
||||||
|
|
||||||
|
connection_string="${ConnectionStrings__DefaultConnection:-}"
|
||||||
|
db_path=""
|
||||||
|
|
||||||
|
case "$connection_string" in
|
||||||
|
*"Data Source="*)
|
||||||
|
db_path="${connection_string#*Data Source=}"
|
||||||
|
db_path="${db_path%%;*}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$(id -u)" = "0" ]; then
|
||||||
|
fix_path_owner "/app/data"
|
||||||
|
|
||||||
|
if [ -n "$db_path" ]; then
|
||||||
|
db_dir="$(dirname "$db_path")"
|
||||||
|
fix_path_owner "$db_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DATA_PROTECTION_KEY_PATH:-}" ]; then
|
||||||
|
fix_path_owner "$DATA_PROTECTION_KEY_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec runuser -u "$APP_USER" -- "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user