website/Dockerfile

42 lines
1.3 KiB
Text
Raw Normal View History

2024-03-22 10:19:46 +00:00
# Builder stage
FROM node:20-alpine AS builder
# Set the working directory in the container
2024-04-12 07:35:09 +00:00
WORKDIR /git
2024-03-22 10:19:46 +00:00
# Copy the repository contents into the container
COPY . .
2024-04-12 07:35:09 +00:00
# Install dependencies and build the site. Output directory will be /git/build
2024-03-22 10:19:46 +00:00
RUN yarn install && yarn run build
# Final stage
FROM caddy:2-alpine
# Set the working directory in the container
2024-04-12 07:35:09 +00:00
WORKDIR /app
2024-03-22 10:19:46 +00:00
2024-04-12 07:35:09 +00:00
# Copy the build directory from the builder stage to /app
COPY --from=builder /git/build /app
2024-03-22 10:19:46 +00:00
2024-04-12 07:35:09 +00:00
# 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
2024-03-22 10:19:46 +00:00
# Expose port 80
EXPOSE 80
# Start Caddy with the specified Caddyfile
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
2024-04-03 13:13:05 +00:00
# Docker Container Labels
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"
2024-04-12 07:35:09 +00:00
LABEL org.opencontainers.image.documentation="https://git.org/sangelo/appsite"
2024-04-03 13:13:05 +00:00
LABEL org.opencontainers.image.vendor="Sangelo"
LABEL org.opencontainers.image.licenses="GPL-v3"
2024-04-12 07:35:09 +00:00
LABEL org.opencontainers.image.source="https://git.org/sangelo/appsite"
# Remove intermediate images after build
2024-04-12 07:35:09 +00:00
ONBUILD RUN rm -rf /git