diff --git a/.dockerignore b/.dockerignore index 7804d53d6..9034881e0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,57 +1,20 @@ # Configuration and environment **/config/ server/.env -.env* # Dependencies/modules **/node_modules/ -# Build/distribution files (these are built fresh in Docker) +# Build/distribution files **/build/ **/dist/ # Version control **/.git/ .gitignore -.gitattributes # IDE files .vscode -.idea -*.swp -*.swo -*~ - -# Testing -**/__tests__/ -**/*.test.ts -**/*.test.tsx -**/*.spec.ts -**/*.spec.tsx -**/coverage/ - -# Documentation -README.md -CHANGELOG.md -LICENSE -**/*.md - -# CI/CD -.github/ -.gitlab-ci.yml -.travis.yml # macOS files -**/.DS_Store -.AppleDouble -.LSOverride - -# Logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Lockfiles for other package managers -yarn.lock -pnpm-lock.yaml \ No newline at end of file +**/.DS_Store \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 40d001277..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "npm" - directory: "/client" - schedule: - interval: "weekly" - target-branch: "staging" - - - package-ecosystem: "npm" - directory: "/server" - schedule: - interval: "weekly" - target-branch: "staging" \ No newline at end of file diff --git a/.github/workflows/build_server.yml b/.github/workflows/build_server.yml index 8d4f3332a..7bbd6002c 100644 --- a/.github/workflows/build_server.yml +++ b/.github/workflows/build_server.yml @@ -14,7 +14,7 @@ jobs: with: node-version: 22 - name: Install dependencies - run: npm install --legacy-peer-deps --prefer-offline --no-audit + run: npm ci --legacy-peer-deps working-directory: ./server - name: Run build run: npm run build diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9f479ce58..019c16411 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,8 +24,6 @@ jobs: if: needs.check_authorization.outputs.isAuthorized == 'true' runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: @@ -36,10 +34,4 @@ jobs: uses: docker/build-push-action@v4 with: push: true - tags: | - ghcr.io/libretexts/conductor:${{ inputs.version }} - ghcr.io/libretexts/conductor:latest - build-args: | - VERSION=${{ inputs.version }} - BUILD_DATE=${{ github.event.repository.updated_at }} - VCS_REF=${{ github.sha }} \ No newline at end of file + tags: ghcr.io/libretexts/conductor:${{ inputs.version }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 831b37e7f..bf34cebfc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,67 +1,36 @@ -# Stage 1: Build client -FROM node:22-alpine3.22 AS client-builder -WORKDIR /usr/src/conductor/client - -# Install git (needed for git dependencies in package.json) -RUN apk add --no-cache git - -# Copy package.json only (let npm resolve dependencies for Linux) -COPY client/package.json ./ -RUN npm install --no-audit - -# Copy source and build -COPY client/ ./ -RUN npm run build - -# Stage 2: Build server -FROM node:22-alpine3.22 AS server-builder -WORKDIR /usr/src/conductor/server - -# Copy package.json only (let npm resolve dependencies for Linux) -COPY server/package.json ./ -RUN npm install --no-audit +FROM node:22-alpine3.22 +LABEL org.opencontainers.image.source="https://github.com/LibreTexts/conductor" -# Copy source and build -COPY server/ ./ -# Ensure public directory exists (even if not in source) -RUN mkdir -p ./public -RUN npm run build +WORKDIR /usr/src/conductor -# Stage 3: Production runtime -FROM node:22-alpine3.22 +COPY . . -# Build arguments for dynamic labels -ARG VERSION=dev -ARG BUILD_DATE -ARG VCS_REF +# Install system dependencies (primarily for canvas) +RUN apk add --update --no-cache \ + make \ + g++ \ + jpeg-dev \ + cairo-dev \ + giflib-dev \ + pango-dev \ + libtool \ + autoconf \ + automake -# OCI Image Labels (https://github.com/opencontainers/image-spec/blob/main/annotations.md) -LABEL org.opencontainers.image.title="LibreTexts Conductor" \ - org.opencontainers.image.description="The LibreTexts Conductor platform Docker image" \ - org.opencontainers.image.version="${VERSION}" \ - org.opencontainers.image.created="${BUILD_DATE}" \ - org.opencontainers.image.revision="${VCS_REF}" \ - org.opencontainers.image.vendor="LibreTexts" \ - org.opencontainers.image.documentation="https://github.com/LibreTexts/conductor/blob/master/README.md" \ - org.opencontainers.image.source="https://github.com/LibreTexts/conductor" \ - org.opencontainers.image.licenses="MIT" +# Install client dependencies and build frontend +WORKDIR /usr/src/conductor/client +RUN npm ci && npm run build +# Install server dependencies WORKDIR /usr/src/conductor/server +RUN npm ci -# Copy package.json only and install ONLY production dependencies -COPY server/package.json ./ -RUN npm install --no-audit --omit=dev && \ - npm cache clean --force - -# Copy built artifacts from previous stages -COPY --from=server-builder /usr/src/conductor/server/dist ./dist -COPY --from=server-builder /usr/src/conductor/server/util ./util -COPY --from=server-builder /usr/src/conductor/server/public ./public -COPY --from=client-builder /usr/src/conductor/client/dist ../client/dist +# Build server +RUN npm run build EXPOSE 5000 -HEALTHCHECK --interval=10s --timeout=5s --start-period=45s --retries=3 \ +HEALTHCHECK --timeout=5s --start-period=30s \ CMD wget -nv -t1 --spider http://localhost:5000/health || exit 1 -ENTRYPOINT [ "node", "dist/server.js" ] +ENTRYPOINT [ "node", "dist/server.js" ] \ No newline at end of file diff --git a/client/index.html b/client/index.html index fed011f10..ce710a73c 100644 --- a/client/index.html +++ b/client/index.html @@ -3,6 +3,7 @@ + LibreCommons @@ -26,8 +27,6 @@ - -