diff --git a/.dockerignore b/.dockerignore index f91d1539a..c9eb575a4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,7 +17,6 @@ # Ignore build folders node_modules **/node_modules -**/dist # Ignore default volumes created by running docker compose up ontime-db diff --git a/.github/workflows/build_cli.yml b/.github/workflows/build_cli.yml index effc09658..54505e195 100644 --- a/.github/workflows/build_cli.yml +++ b/.github/workflows/build_cli.yml @@ -13,13 +13,13 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Setup pnpm uses: pnpm/action-setup@v4 - name: Get pnpm store directory run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - + - name: Setup pnpm cache uses: actions/cache@v4 with: @@ -38,16 +38,20 @@ jobs: - name: Copy server run: mkdir -p apps/cli/server && cp apps/server/dist/index.cjs apps/cli/server/index.cjs - + - name: Copy client run: cp -R apps/client/build apps/cli/client - name: Copy external run: cp -R apps/server/src/external apps/cli/external - + + - name: Setup pnpm auth config + run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + - name: Publish to NPM run: pnpm publish --access public --no-git-checks env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true working-directory: ./apps/cli diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index ca8c5b0b7..263a80942 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -6,43 +6,63 @@ on: workflow_dispatch: jobs: - publish_docker: runs-on: ubuntu-latest env: CI: '' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Docker Login - uses: docker/login-action@v2.1.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup pnpm + uses: pnpm/action-setup@v4 - - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v2.5.0 + - name: Get pnpm store directory + run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - name: Build and push stable release - if: github.event.release.prerelease == false - uses: docker/build-push-action@v4.0.0 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7 - # Push is a shorthand for --output=type=registry - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/ontime:${{ github.event.release.tag_name }} , ${{ secrets.DOCKERHUB_USERNAME }}/ontime:latest + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - - name: Build and push pre-release - if: github.event.release.prerelease == true - uses: docker/build-push-action@v4.0.0 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7 - # Push is a shorthand for --output=type=registry - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/ontime:${{ github.event.release.tag_name }} , ${{ secrets.DOCKERHUB_USERNAME }}/ontime:nightly + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Build project packages + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + run: pnpm build:docker + + - name: Docker Login + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2.5.0 + + - name: Build and push stable release + if: github.event.release.prerelease == false + uses: docker/build-push-action@v4.0.0 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64,linux/arm/v7 + # Push is a shorthand for --output=type=registry + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/ontime:${{ github.event.release.tag_name }} , ${{ secrets.DOCKERHUB_USERNAME }}/ontime:latest + + - name: Build and push pre-release + if: github.event.release.prerelease == true + uses: docker/build-push-action@v4.0.0 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64,linux/arm/v7 + # Push is a shorthand for --output=type=registry + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/ontime:${{ github.event.release.tag_name }} , ${{ secrets.DOCKERHUB_USERNAME }}/ontime:nightly diff --git a/.github/workflows/build_electron.yml b/.github/workflows/build_electron.yml index 29b253124..ef39682e2 100644 --- a/.github/workflows/build_electron.yml +++ b/.github/workflows/build_electron.yml @@ -2,7 +2,7 @@ name: Ontime build on: push: - tags: [ "*" ] + tags: ['*'] workflow_dispatch: jobs: @@ -11,13 +11,13 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Setup pnpm uses: pnpm/action-setup@v4 - name: Get pnpm store directory run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - + - name: Setup pnpm cache uses: actions/cache@v4 with: @@ -35,7 +35,7 @@ jobs: run: pnpm build - name: Electron - Build app - env: + env: APPLE_ID: ${{ secrets.APPLEID }} APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLEIDPASS }} APPLE_TEAM_ID: ${{ secrets.TEAMID }} diff --git a/.github/workflows/build_resolver.yml b/.github/workflows/build_resolver.yml index 8f763fd4d..1e0f8d320 100644 --- a/.github/workflows/build_resolver.yml +++ b/.github/workflows/build_resolver.yml @@ -13,13 +13,13 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Setup pnpm uses: pnpm/action-setup@v4 - name: Get pnpm store directory run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - + - name: Setup pnpm cache uses: actions/cache@v4 with: @@ -34,9 +34,13 @@ jobs: - name: Build project packages run: pnpm build:resolver + - name: Setup pnpm auth config + run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + - name: Publish to NPM run: pnpm publish --access public --no-git-checks env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true working-directory: ./apps/resolver diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66cdd12e4..a68b00674 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: - name: Get pnpm store directory run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - + - name: Setup pnpm cache uses: actions/cache@v4 with: @@ -32,10 +32,10 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - # Run code quality + # Run code quality - name: Run linter run: pnpm lint - + - name: Run TypeScript checks run: pnpm typecheck @@ -56,7 +56,7 @@ jobs: - name: Get pnpm store directory run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - + - name: Setup pnpm cache uses: actions/cache@v4 with: @@ -74,7 +74,7 @@ jobs: uses: actions/cache@v4 with: path: | - ~/.cache/ms-playwright + ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} restore-keys: | ${{ runner.os }}-playwright- diff --git a/.prettierignore b/.prettierignore index 46cb21864..2f6778d66 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,8 +5,9 @@ node_modules playwright-report + +pnpm-lock.yaml **/*.toml -**/*.yml **/*.json !tsconfig.common.json !turbo.json diff --git a/Dockerfile b/Dockerfile index 58480312b..66ca191d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,5 @@ -FROM node:22-bullseye AS builder -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN npm install -g pnpm@10.11.0 -COPY . /app -WORKDIR /app -RUN pnpm --filter=ontime-ui --filter=ontime-server --filter=ontime-utils --filter=ontime-types install --config.dedupe-peer-dependents=false --frozen-lockfile -RUN pnpm run build:docker - -FROM node:22-alpine +ARG NODE_VERSION=22.15.1 +FROM node:${NODE_VERSION}-alpine # Set environment variables # Environment Variable to signal that we are running production @@ -15,16 +7,17 @@ ENV NODE_ENV=docker # Ontime Data path ENV ONTIME_DATA=/data/ +RUN mkdir /app WORKDIR /app/ # Prepare UI -COPY --from=builder /app/apps/client/build ./client/ +COPY apps/client/build/ ./client/ # Prepare Backend -COPY --from=builder /app/apps/server/dist/ ./server/ -COPY --from=builder /app/apps/server/src/external/ ./external/ -COPY --from=builder /app/apps/server/src/user/ ./user/ -COPY --from=builder /app/apps/server/src/html/ ./html/ +COPY apps/server/dist/ ./server/ +COPY apps/server/src/external/ ./external/ +COPY apps/server/src/user/ ./user/ +COPY apps/server/src/html/ ./html/ # Export default ports EXPOSE 4001/tcp 8888/udp 9999/udp @@ -32,5 +25,6 @@ EXPOSE 4001/tcp 8888/udp 9999/udp CMD ["node", "server/docker.cjs"] # Build and run commands +# pnpm build:docker # docker buildx build . -t getontime/ontime # docker run -p 4001:4001 -p 8888:8888/udp -p 9999:9999/udp -v ./ontime-db:/data/ getontime/ontime diff --git a/package.json b/package.json index 77fc9a66f..285c47f27 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "typecheck": "turbo run typecheck", "build": "turbo run build", "build:docker": "cross-env NODE_ENV=docker turbo run build --filter=ontime-server --filter=ontime-ui", + "build:resolver": "cross-env turbo run build --filter=@getontime/resolver", "dist-win": "turbo run dist-win", "dist-mac": "turbo run dist-mac", "dist-linux": "turbo run dist-linux",