Skip to content

Commit fb2a7d8

Browse files
committed
Update dir and user names used in Docker
1 parent dc92ab5 commit fb2a7d8

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

Dockerfile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Build arguments
44
ARG KAMAL_DEPLOY_HOST
55
ARG SERVICESTACK_LICENSE
6+
ARG APP_PASSWORD
67
ARG SERVICE_LABEL
78

89
# 1. Build .NET app + Node.js apps
@@ -30,9 +31,9 @@ COPY MyApp.ServiceModel ./MyApp.ServiceModel
3031
WORKDIR /src/MyApp
3132

3233
# Download tailwindcss binary directly (avoiding sudo requirement in postinstall.js)
33-
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
34-
&& chmod +x tailwindcss-linux-x64 \
35-
&& mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss
34+
RUN curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
35+
-o /usr/local/bin/tailwindcss \
36+
&& chmod +x /usr/local/bin/tailwindcss
3637
RUN npm run ui:build
3738

3839
# Build Next.js app
@@ -67,18 +68,18 @@ RUN apt-get update \
6768
&& apt-get clean \
6869
&& rm -rf /var/lib/apt/lists/*
6970

70-
# Create unprivileged user for Node.js
71-
RUN groupadd -r nodeuser && useradd -r -g nodeuser -s /bin/bash nodeuser
71+
# Create unprivileged user for Next.js
72+
RUN groupadd -r nextjs && useradd -r -g nextjs -s /bin/bash nextjs
7273

73-
# Copy published .NET app (owned by root, no access for nodeuser)
74-
COPY --from=dotnet-build /src/MyApp/bin/Release/net10.0/publish ./api
75-
RUN chmod -R 700 ./api && chown -R root:root ./api
74+
# Copy published .NET app (owned by root, no access for nextjs user)
75+
COPY --from=dotnet-build /src/MyApp/bin/Release/net10.0/publish ./dotnet
76+
RUN chmod -R 700 ./dotnet && chown -R root:root ./dotnet
7677

77-
# Copy built Next.js app (owned by nodeuser, read-only)
78-
COPY --from=dotnet-build /src/MyApp.Client ./client
79-
RUN chown -R nodeuser:nodeuser ./client && chmod -R 500 ./client
78+
# Copy built Next.js app (owned by nextjs user, read-only)
79+
COPY --from=dotnet-build /src/MyApp.Client ./nextjs
80+
RUN chown -R nextjs:nextjs ./nextjs && chmod -R 500 ./nextjs
8081

81-
# Create /tmp directory accessible to nodeuser
82+
# Create /tmp directory accessible to nextjs user
8283
RUN mkdir -p /tmp && chmod 1777 /tmp
8384

8485
ENV ASPNETCORE_URLS=http://0.0.0.0:8080 \

entrypoint.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ NEXT_PORT="${NEXT_PORT:-3000}"
77
# If running an AppTask (e.g. --AppTasks=migrate), run only the .NET app and exit
88
if [[ "$*" == *"--AppTasks"* ]]; then
99
echo "Running AppTask with args: $*"
10-
ASPNETCORE_CONTENTROOT="/app/api" ASPNETCORE_URLS="${ASPNETCORE_URLS}" \
11-
dotnet /app/api/MyApp.dll "$@"
10+
ASPNETCORE_CONTENTROOT="/app/dotnet" ASPNETCORE_URLS="${ASPNETCORE_URLS}" \
11+
dotnet /app/dotnet/MyApp.dll "$@"
1212
exit $?
1313
fi
1414

1515
echo "Starting ASP.NET Core on ${ASPNETCORE_URLS}..."
1616

1717
# Start ASP.NET Core application as root with full environment
18-
ASPNETCORE_CONTENTROOT="/app/api" ASPNETCORE_URLS="${ASPNETCORE_URLS}" dotnet /app/api/MyApp.dll &
18+
ASPNETCORE_CONTENTROOT="/app/dotnet" ASPNETCORE_URLS="${ASPNETCORE_URLS}" dotnet /app/dotnet/MyApp.dll &
1919
DOTNET_PID=$!
2020

2121
echo "Starting Next.js on port ${NEXT_PORT} as isolated user..."
2222

2323
# Start Node.js with minimal environment and as unprivileged user
2424
# Only pass through safe environment variables
25-
cd /app/client && su nodeuser -s /bin/bash -c "
25+
cd /app/nextjs && su nextjs -s /bin/bash -c "
2626
export HOME=/tmp
2727
export NODE_ENV=production
2828
export NEXT_PORT=${NEXT_PORT}
2929
export INTERNAL_API_URL=${INTERNAL_API_URL:-http://127.0.0.1:8080}
3030
export KAMAL_DEPLOY_HOST=${KAMAL_DEPLOY_HOST}
3131
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
32-
cd /app/client
32+
cd /app/nextjs
3333
npm run start -- --port ${NEXT_PORT}
3434
" &
3535
NEXT_PID=$!

0 commit comments

Comments
 (0)