From 24e0e9f29befaa092035c1c1f6d3acdfd0fbf9a9 Mon Sep 17 00:00:00 2001 From: Sangelo Date: Fri, 12 Apr 2024 09:35:09 +0200 Subject: [PATCH] [c] Dockerfile refactoring --- Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index c7216c6..badce20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,25 +2,25 @@ FROM node:20-alpine AS builder # Set the working directory in the container -WORKDIR /app +WORKDIR /git # Copy the repository contents into the container COPY . . -# Install dependencies and build the site. Output directory will be /app/build +# Install dependencies and build the site. Output directory will be /git/build RUN yarn install && yarn run build # Final stage FROM caddy:2-alpine # Set the working directory in the container -WORKDIR /web +WORKDIR /app -# Copy the build directory from the builder stage to /web -COPY --from=builder /app/build /web +# Copy the build directory from the builder stage to /app +COPY --from=builder /git/build /app -# Caddyfile configuration to serve files from /web -RUN echo -e ":80 {\n root * /web\n file_server\n}" > /etc/caddy/Caddyfile +# Caddyfile configuration to serve files from /app +RUN echo -e ":80 {\n root * /app\n try_files {path}.html {path}\n file_server\n}" > /etc/caddy/Caddyfile # Expose port 80 EXPOSE 80 @@ -32,10 +32,10 @@ CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile LABEL org.opencontainers.image.title="Sangelo's Space" LABEL org.opencontainers.image.description="Sangelo's Space website, packaged as a docker container, with the Caddy webserver." LABEL org.opencontainers.image.url="https://sangelo.space" -LABEL org.opencontainers.image.documentation="https://gitpot.org/sangelo/website" +LABEL org.opencontainers.image.documentation="https://git.org/sangelo/appsite" LABEL org.opencontainers.image.vendor="Sangelo" LABEL org.opencontainers.image.licenses="GPL-v3" -LABEL org.opencontainers.image.source="https://gitpot.org/sangelo/website" +LABEL org.opencontainers.image.source="https://git.org/sangelo/appsite" # Remove intermediate images after build -ONBUILD RUN rm -rf /app +ONBUILD RUN rm -rf /git