diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..14f7215 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,40 @@ +name: Build and Deploy + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build Docker image + run: docker build -t my-app . + + - name: Log in to Docker registry + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Tag Docker image + run: docker tag my-app my-registry/my-app:${{ github.run_number }} + + - name: Push Docker image to registry + run: docker push my-registry/my-app:${{ github.run_number }} + + - name: Connect to remote host + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.REMOTE_HOST }} + username: ${{ secrets.REMOTE_USER }} + password: ${{ secrets.REMOTE_PASSWORD }} + + - name: Pull and run docker compose + run: | + docker pull + docker-compose up -d diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be55ecb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Builder stage +FROM node:22-alpine AS builder +WORKDIR /app +COPY package*.json ./ +COPY . . +RUN node setup.js +RUN npm ci +RUN npm run build + +# Runner stage +FROM node:22-alpine +WORKDIR /app +COPY --from=builder /app/build ./build +RUN npm install -g serve +EXPOSE 32100 +CMD ["serve", "-s", "build", "-l", "32100"] \ No newline at end of file diff --git a/README.md b/README.md index b2af5b4..5239d1b 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,16 @@ grant usage on schema public to anon, authenticated; grant all on table timers to anon, authenticated; ``` +### Automatic Session Closure (Optional) + +To automatically close active sessions at midnight every day (without deleting history): + +1. Make sure the `pg_cron` extension is enabled in your Supabase project (it's usually enabled by default) +2. Run the SQL script in `supabase/close_sessions_cron.sql` in your Supabase SQL Editor +3. The cron job will automatically run daily at 00:00 to close any active sessions + +The function identifies sessions that are currently active (where `end_time` is NULL) and sets their `end_time` to midnight, calculating the duration accordingly. This preserves all session history while ensuring no session remains indefinitely open. + ## Session Management Features ### Creating New Sessions diff --git a/package.json b/package.json index 2354cbb..cebd4fa 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "setup": "node setup.js" + "setup": "node setup.js", + "close-active-sessions": "node scripts/closeSessions.js" }, "eslintConfig": { "extends": [ diff --git a/public/index.html b/public/index.html index f3e7dee..fe61449 100644 --- a/public/index.html +++ b/public/index.html @@ -5,39 +5,38 @@ - - - + + + + + + + + + + + - -