diff --git a/Dockerfile b/Dockerfile index 8bc4906..f08101f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,20 +15,70 @@ RUN corepack enable # Will be overridden at runtime with the actual server endpoint ENV NEXT_PUBLIC_ENTE_ENDPOINT="https://localhost:8080" -# Build all web apps -RUN cd web && \ - yarn cache clean && \ - yarn install --network-timeout 1000000000 && \ - yarn build:photos && \ - yarn build:accounts && \ - yarn build:auth && \ - yarn build:cast +# Debugging the repository structure +RUN find . -type d -maxdepth 3 | sort + +# Check if web directory exists with apps subdirectory +RUN mkdir -p /build/web/photos /build/web/accounts /build/web/auth /build/web/cast && \ + if [ -d "web" ] && [ -d "web/apps" ]; then \ + echo "Found web/apps directory, building web apps"; \ + cd web && \ + yarn cache clean && \ + yarn install --network-timeout 1000000000 && \ + yarn build:photos && \ + yarn build:accounts && \ + yarn build:auth && \ + yarn build:cast && \ + if [ -d "apps/photos/out" ]; then \ + cp -r apps/photos/out/* /build/web/photos/; \ + fi && \ + if [ -d "apps/accounts/out" ]; then \ + cp -r apps/accounts/out/* /build/web/accounts/; \ + fi && \ + if [ -d "apps/auth/out" ]; then \ + cp -r apps/auth/out/* /build/web/auth/; \ + fi && \ + if [ -d "apps/cast/out" ]; then \ + cp -r apps/cast/out/* /build/web/cast/; \ + fi; \ + elif [ -d "web" ]; then \ + echo "Found web directory, looking for alternative structure"; \ + find web -type d | grep -v node_modules | sort; \ + if [ -d "web/photos" ]; then \ + echo "Building photos app"; \ + cd web/photos && yarn install && yarn build && \ + if [ -d "out" ]; then cp -r out/* /build/web/photos/; fi; \ + fi; \ + if [ -d "web/accounts" ]; then \ + echo "Building accounts app"; \ + cd web/accounts && yarn install && yarn build && \ + if [ -d "out" ]; then cp -r out/* /build/web/accounts/; fi; \ + fi; \ + if [ -d "web/auth" ]; then \ + echo "Building auth app"; \ + cd web/auth && yarn install && yarn build && \ + if [ -d "out" ]; then cp -r out/* /build/web/auth/; fi; \ + fi; \ + if [ -d "web/cast" ]; then \ + echo "Building cast app"; \ + cd web/cast && yarn install && yarn build && \ + if [ -d "out" ]; then cp -r out/* /build/web/cast/; fi; \ + fi; \ + else \ + echo "Web directory not found, creating placeholder web pages"; \ + # Create placeholder HTML files for each app \ + mkdir -p /build/web/photos /build/web/accounts /build/web/auth /build/web/cast; \ + echo "
Web app not available. Please check the build logs.
" > /build/web/photos/index.html; \ + echo "Web app not available. Please check the build logs.
" > /build/web/accounts/index.html; \ + echo "Web app not available. Please check the build logs.
" > /build/web/auth/index.html; \ + echo "Web app not available. Please check the build logs.
" > /build/web/cast/index.html; \ + fi FROM cloudron/base:5.0.0@sha256:04fd70dbd8ad6149c19de39e35718e024417c3e01dc9c6637eaf4a41ec4e596c # Install necessary packages for both Go and Node.js RUN apt-get update && \ - apt-get install -y curl git nodejs npm golang libsodium23 libsodium-dev pkg-config && \ + apt-get install -y curl git nodejs npm golang libsodium23 libsodium-dev pkg-config nginx && \ npm install -g yarn serve && \ apt-get clean && apt-get autoremove && \ rm -rf /var/cache/apt /var/lib/apt/lists @@ -42,10 +92,10 @@ WORKDIR /app/code RUN git clone --depth=1 https://github.com/ente-io/ente.git . # Copy the web app built files from the first stage -COPY --from=web-builder /ente/web/apps/photos/out /app/web/photos -COPY --from=web-builder /ente/web/apps/accounts/out /app/web/accounts -COPY --from=web-builder /ente/web/apps/auth/out /app/web/auth -COPY --from=web-builder /ente/web/apps/cast/out /app/web/cast +COPY --from=web-builder /build/web/photos /app/web/photos +COPY --from=web-builder /build/web/accounts /app/web/accounts +COPY --from=web-builder /build/web/auth /app/web/auth +COPY --from=web-builder /build/web/cast /app/web/cast # Copy configuration and startup scripts ADD start.sh /app/pkg/ @@ -54,6 +104,9 @@ ADD config.template.yaml /app/pkg/ # Set proper permissions RUN chmod +x /app/pkg/start.sh +# Create NGINX directories +RUN mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled + # Expose the web port (Cloudron expects port 8080) EXPOSE 8080 diff --git a/start.sh b/start.sh index faed159..44d063e 100644 --- a/start.sh +++ b/start.sh @@ -5,13 +5,27 @@ set -eu # Create necessary directories mkdir -p /app/data/config /app/data/storage -# Print debug information about repository structure -echo "==> DEBUG: Repository structure at /app/code" -find /app/code -type d -not -path "*/node_modules/*" -not -path "*/\.*" | sort +echo "==> DEBUG: Full repository structure at /app/code" +find /app/code -type d -maxdepth 3 -not -path "*/node_modules/*" -not -path "*/\.*" | sort + +echo "==> DEBUG: Looking for Go files" +find /app/code -name "*.go" | grep -v test | sort | head -10 + +echo "==> DEBUG: Looking for server-related directories" +find /app/code -type d -path "*/server*" -o -path "*/museum*" | sort + echo "==> DEBUG: All package.json files in repository" find /app/code -name "package.json" -not -path "*/node_modules/*" | sort -echo "==> DEBUG: Web app directories" -ls -la /app/web + +echo "==> DEBUG: Looking for web app directories" +find /app/code -type d -path "*/web*" | sort + +echo "==> DEBUG: Web app directories in /app/web (if they exist)" +if [ -d "/app/web" ]; then + ls -la /app/web +else + echo "Web app directory not yet copied to /app/web" +fi # Create config template file on first run if [[ ! -f /app/data/config/config.yaml ]]; then @@ -91,10 +105,19 @@ sed -i \ -e "s|%%S3_PREFIX%%|${S3_PREFIX:-ente/}|g" \ /app/data/config/config.yaml +# Install or verify required packages +echo "==> Checking for required packages" +if ! command -v nginx &> /dev/null; then + echo "==> Installing NGINX" + apt-get update && apt-get install -y nginx +fi + # Set up NGINX to serve the web apps and proxy to the Museum server echo "==> Setting up NGINX for web apps and API" # Create NGINX configuration +mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled + cat > /etc/nginx/sites-available/ente <The Ente Museum server could not be started because no suitable Go source files were found.
") + fmt.Fprintf(w, "Please check the logs for more information.
") + fmt.Fprintf(w, "