images/ente/web/Dockerfile

59 lines
1.5 KiB
Text
Raw Normal View History

2024-05-15 14:38:48 +00:00
# syntax=docker/dockerfile:1
FROM node:21-bookworm-slim as ente-builder
2024-05-15 15:58:55 +00:00
ARG ENTE_BRANCH=main
2024-05-18 17:25:44 +00:00
ARG ENTE_APP=photos
2024-05-15 15:58:55 +00:00
2024-05-15 14:38:48 +00:00
ENV NEXT_PUBLIC_ENTE_ENDPOINT=DOCKER_RUNTIME_REPLACE_ENDPOINT \
NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=DOCKER_RUNTIME_REPLACE_ALBUMS_ENDPOINT
RUN apt update && apt install -y ca-certificates git git-lfs && rm -rf /var/lib/apt/lists/*
WORKDIR /app
2024-05-15 15:58:55 +00:00
RUN git clone --recursive --depth=1 --shallow-submodules --branch="${ENTE_BRANCH}" https://github.com/ente-io/ente.git .
2024-05-15 14:38:48 +00:00
WORKDIR /app/web
RUN yarn install && \
2024-05-18 17:25:44 +00:00
yarn build:${ENTE_APP}
2024-05-15 14:38:48 +00:00
2024-05-15 16:08:37 +00:00
FROM nginx:1.26-alpine-slim
2024-05-18 17:25:44 +00:00
ARG ENTE_APP=photos
COPY --from=ente-builder /app/web/apps/${ENTE_APP}/out /usr/share/nginx/html
2024-05-15 14:38:48 +00:00
COPY <<EOF /etc/nginx/conf.d/default.conf
server {
listen 3000 default_server;
root /usr/share/nginx/html;
location / {
try_files \$uri \$uri.html \$uri/ =404;
}
error_page 404 /404.html;
location = /404.html {
internal;
}
}
EOF
ARG ENDPOINT="http://localhost:8080"
ENV ENDPOINT "$ENDPOINT"
ARG ALBUMS_ENDPOINT="http://localhost:8082"
ENV ALBUMS_ENDPOINT "$ALBUMS_ENDPOINT"
COPY <<EOF /docker-entrypoint.d/replace_ente_endpoints.sh
echo "Replacing endpoints"
echo " Endpoint: \$ENDPOINT"
echo " Albums Endpoint: \$ALBUMS_ENDPOINT"
replace_enpoints() {
sed -i -e 's,DOCKER_RUNTIME_REPLACE_ENDPOINT,'"\$ENDPOINT"',g' \$1
sed -i -e 's,DOCKER_RUNTIME_REPLACE_ALBUMS_ENDPOINT,'"\$ALBUMS_ENDPOINT"',g' \$1
}
for jsfile in `find '/usr/share/nginx/html' -type f -name '*.js'`
do
replace_enpoints "\$jsfile"
done
EOF
RUN chmod +x /docker-entrypoint.d/replace_ente_endpoints.sh