2021-04-21 14:16:56 +00:00
|
|
|
## BUILD STAGE
|
2023-11-23 10:54:08 +00:00
|
|
|
FROM node:18 as build-stage
|
2021-04-13 14:04:14 +00:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
2023-07-05 08:43:57 +00:00
|
|
|
# Update platform dependencies
|
2021-04-21 14:16:56 +00:00
|
|
|
RUN apt-get update && apt-get install libsecret-1-0 -y
|
2023-07-05 08:43:57 +00:00
|
|
|
|
|
|
|
# Prepare native plugin
|
|
|
|
COPY ./cordova-plugin-moodleapp/package*.json /app/cordova-plugin-moodleapp/
|
|
|
|
RUN npm ci --prefix cordova-plugin-moodleapp
|
|
|
|
COPY ./cordova-plugin-moodleapp/ /app/cordova-plugin-moodleapp/
|
|
|
|
RUN npm run prod --prefix cordova-plugin-moodleapp
|
|
|
|
|
|
|
|
# Prepare node dependencies
|
2021-04-21 14:14:06 +00:00
|
|
|
COPY package*.json ./
|
2023-02-21 13:02:48 +00:00
|
|
|
COPY patches ./patches
|
|
|
|
RUN echo "unsafe-perm=true" > ./.npmrc
|
2022-01-14 11:11:20 +00:00
|
|
|
RUN npm ci --no-audit
|
2021-04-21 14:14:06 +00:00
|
|
|
|
2021-04-21 14:16:56 +00:00
|
|
|
# Build source
|
|
|
|
ARG build_command="npm run build:prod"
|
2021-04-21 14:14:06 +00:00
|
|
|
COPY . /app
|
2021-04-21 14:16:56 +00:00
|
|
|
RUN ${build_command}
|
2021-04-13 14:04:14 +00:00
|
|
|
|
2024-02-01 16:04:40 +00:00
|
|
|
# Generate SSL certificate
|
|
|
|
RUN mkdir /app/ssl
|
|
|
|
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /app/ssl/certificate.key -out /app/ssl/certificate.crt -subj="/O=Moodle"
|
|
|
|
|
2021-04-21 14:16:56 +00:00
|
|
|
## SERVE STAGE
|
|
|
|
FROM nginx:alpine as serve-stage
|
2021-04-13 14:04:14 +00:00
|
|
|
|
2021-05-04 07:30:08 +00:00
|
|
|
# Copy assets & config
|
2021-04-21 14:16:56 +00:00
|
|
|
COPY --from=build-stage /app/www /usr/share/nginx/html
|
2024-02-01 16:04:40 +00:00
|
|
|
COPY --from=build-stage /app/ssl/certificate.crt /etc/ssl/certificate.crt
|
|
|
|
COPY --from=build-stage /app/ssl/certificate.key /etc/ssl/certificate.key
|
2021-05-04 07:30:08 +00:00
|
|
|
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
2024-02-01 16:04:40 +00:00
|
|
|
EXPOSE 443
|
|
|
|
HEALTHCHECK --interval=10s --timeout=4s CMD curl --insecure -f https://localhost/assets/env.json || exit 1
|