Runtime configurable env vars

This commit is contained in:
Manav Rathi
2025-03-19 15:01:39 +05:30
parent a28932c319
commit dfda91b99b

View File

@@ -1,11 +1,5 @@
FROM node:20-alpine AS builder
ARG ENTE_API_ORIGIN=http://localhost:8080
ARG ENTE_ALBUMS_APP_ORIGIN=https://localhost:3002
ENV NEXT_PUBLIC_ENTE_ENDPOINT="$ENTE_API_ORIGIN"
ENV NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT="$ENTE_ALBUMS_APP_ORIGIN"
WORKDIR /build
COPY . .
@@ -20,7 +14,6 @@ FROM nginx
WORKDIR /out
COPY --from=builder /build/apps/photos/out /out/photos
COPY --from=builder /build/apps/photos/out /out/albums
COPY --from=builder /build/apps/accounts/out /out/accounts
COPY --from=builder /build/apps/auth/out /out/auth
COPY --from=builder /build/apps/cast/out /out/cast
@@ -35,7 +28,7 @@ server {
location / { try_files \$uri \$uri/ \$uri.html /index.html; }
}
server {
listen 3002; root /out/albums;
listen 3002; root /out/photos;
location / { try_files \$uri \$uri/ \$uri.html /index.html; }
}
server {
@@ -53,3 +46,13 @@ EXPOSE 3001
EXPOSE 3002
EXPOSE 3003
EXPOSE 3004
ENV ENTE_API_ORIGIN=http://localhost:8080
ENV ENTE_ALBUMS_ORIGIN=https://localhost:3002
COPY <<EOF /docker-entrypoint.d/replace-ente-env.sh
find /out -name '*.js' | xargs sed -i'' "s#https://api.ente.io#\$ENTE_API_ORIGIN#"
find /out/photos -name '*.js' | xargs sed -i'' "s#https://albums.ente.io#\$ENTE_ALBUMS_ORIGIN#"
EOF
RUN chmod +x /docker-entrypoint.d/replace-ente-env.sh