Skip to content

Commit

Permalink
[OneBot] fix docker failed
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRRb committed Feb 6, 2025
1 parent e534eaf commit 6c02fd7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/Lagrange.OneBot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ jobs:
linux-arm,
linux-arm64,
osx-x64,
osx-arm64,
linux-musl-x64,
linux-musl-arm,
linux-musl-arm64,
osx-arm64
]

steps:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/Lagrange.OneBot-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ jobs:
linux-arm,
linux-arm64,
osx-x64,
osx-arm64,
linux-musl-x64,
linux-musl-arm,
linux-musl-arm64,
osx-arm64
]

steps:
Expand Down
11 changes: 4 additions & 7 deletions Lagrange.OneBot/Resources/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build-env

WORKDIR /root/build
ARG TARGETARCH
Expand All @@ -9,18 +9,15 @@ RUN dotnet publish -p:DebugType="none" -a $TARGETARCH -f "net9.0" -o "/root/out"

# ===

FROM mcr.microsoft.com/dotnet/runtime:9.0-alpine
FROM mcr.microsoft.com/dotnet/runtime:9.0-bookworm-slim

WORKDIR /app/data

COPY --from=build-env /root/out /app/bin
COPY Lagrange.OneBot/Resources/docker-entrypoint.sh /app/bin/docker-entrypoint.sh

ENV UID=100
ENV GID=100

RUN apk --no-cache add shadow su-exec \
&& adduser -D user \
RUN apt-get update \
&& apt-get -y --no-install-recommends install gosu \
&& chmod +x /app/bin/docker-entrypoint.sh

ENTRYPOINT ["/app/bin/docker-entrypoint.sh"]
20 changes: 11 additions & 9 deletions Lagrange.OneBot/Resources/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/sh

USER=user

usermod -o -u ${UID} ${USER} > /dev/null
groupmod -o -g ${GID} ${USER} > /dev/null
usermod -g ${GID} ${USER} > /dev/null

chown -R ${UID}:${GID} /app > /dev/null

exec su-exec $USER /app/bin/Lagrange.OneBot "$@"
USER_ID=${LOCAL_USER_ID:-0}

if [ "$USER_ID" -ne 0 ]; then
chown -R $USER_ID /app/data
useradd --shell /bin/sh -u $USER_ID -o -c "" -m user
usermod -a -G root user
export HOME=/home/user
exec /usr/sbin/gosu user /app/bin/Lagrange.OneBot "$@"
else
exec /app/bin/Lagrange.OneBot "$@"
fi

0 comments on commit 6c02fd7

Please sign in to comment.