# Dockerfile untuk SPA Nuxt 3
FROM node:23-alpine AS builder

WORKDIR /app

COPY package*.json ./
RUN npm install --legacy-peer-deps

COPY . .

ARG API_BASE_URL
ARG CLIENT_ID
ARG CLIENT_SECRET
ENV API_BASE_URL=$API_BASE_URL
ENV CLIENT_ID=$CLIENT_ID
ENV CLIENT_SECRET=$CLIENT_SECRET

RUN npm run generate

# Dockerfile untuk server Nuxt 3
FROM nginx:1.29-alpine

RUN rm -rf /var/www/html/* && \
    rm -f /etc/nginx/conf.d/default.conf
# COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/

COPY --from=builder /app/.output/public /var/www/html

RUN chown -R nginx:nginx /var/www/html && \
    chmod -R 755 /var/www/html

RUN ln -s /var/www/html /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
