# outlook-addin-cdn — serves ClickOnce artifacts at platform.dev.marcus-law.co.il/outlook-addin/*
#
# The publish/ directory (produced by the Windows job) is copied into the image
# along with a custom nginx.conf that maps the ClickOnce-specific MIME types.
# Each release tag produces a versioned image (e.g. :v1.0.0) + :latest.

FROM nginx:1.27-alpine

# Drop the default site config; our nginx.conf is the only one.
RUN rm -f /etc/nginx/conf.d/default.conf

COPY nginx.conf /etc/nginx/conf.d/outlook-addin.conf
# Coolify adds a StripPrefix middleware for the /outlook-addin path, so nginx
# sees requests at the root (/OutlookAddin.vsto, etc) -- copy files to the
# nginx root accordingly.
COPY publish/   /usr/share/nginx/html/

# nginx runs as non-root by default in the alpine image; ensure files readable.
RUN chmod -R a+rX /usr/share/nginx/html

EXPOSE 80

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
    CMD wget -qO- http://localhost/health || exit 1
