Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Main into dcrepublic-dev #11

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ name: Node.js CI
on:
push:
branches: [ "main", "dcrepublic-dev", "v6ctor-dev"]
pull_request:
branches: [ "main" ]

jobs:
build:
Expand All @@ -16,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:lts-bookworm
ARG DATABASE_URL
ENV NODE_ENV=production

RUN apt-get update
RUN apt-get install -y vim netcat-openbsd

WORKDIR /usr/src/app
COPY . .
EXPOSE 3000

RUN chown -R node /usr/src/app
USER node
RUN npm install --production
RUN npx prisma generate
RUN DATABASE_URL=$DATABASE_URL npm run build
CMD ["npm", "start"]
26 changes: 26 additions & 0 deletions Dockerfile.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.23-bookworm

RUN useradd cronuser
RUN mkdir -p /app
RUN chown -R cronuser /app
WORKDIR /app

RUN apt update
RUN apt install -y cron rsyslog

COPY --chown=cronuser:cronuser ./crontab_file /etc/cron.d/cron-scraper
RUN crontab -u cronuser /etc/cron.d/cron-scraper
RUN chmod u+s /usr/sbin/cron
COPY --chown=cronuser:cronuser ./cron-startup.sh ./cron-startup.sh

USER cronuser

COPY ./swatscraper/go.mod ./swatscraper/go.sum ./
RUN go mod download

COPY --chown=cronuser:cronuser ./.env ./.env
COPY --chown=cronuser:cronuser ./swatscraper/*.go ./

RUN GOCACHE=/app/.cache CGO_ENABLED=0 GOOS=linux go build -o /app/swatscraper

ENTRYPOINT ["./cron-startup.sh"]
3 changes: 3 additions & 0 deletions cron-startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo "Start cron"
cron -f
1 change: 1 addition & 0 deletions crontab_file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 * * * * /app/swatscraper
64 changes: 64 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
services:
scheduler:
image: registry.sccs.swarthmore.edu/sccs/scheduler/scheduler:latest
build:
context: .
dockerfile: ./Dockerfile
restart: unless-stopped
env_file:
- .env
environment:
NODE_ENV: production
DOMAIN: https://schedulerv2.sccs.swarthmore.edu
depends_on:
- scheduler-db
deploy:
labels:
- 'traefik.enable=true'
- 'traefik.docker.network=traefik'
- 'traefik.http.routers.scheduler.entrypoints=https'
- 'traefik.http.routers.scheduler.rule=Host(`schedulerv2.sccs.swarthmore.edu`)'
- 'traefik.http.routers.scheduler.tls=true'
- 'traefik.http.routers.scheduler.tls.certresolver=letsEncrypt'
- 'traefik.http.services.scheduler.loadbalancer.server.port=3000'
command: sh -c "sleep 5 && npx prisma migrate deploy && npm start "
networks:
- traefik
- internal

scheduler-db:
hostname: scheduler-db
image: postgres:16.4-bullseye
volumes:
- scheduler-dbdata:/var/lib/postgresql/data
env_file:
- .env
networks:
- internal

scheduler-cron:
image: registry.sccs.swarthmore.edu/sccs/scheduler/scheduler-cron:latest
build:
context: .
dockerfile: ./Dockerfile.cron
restart: unless-stopped
depends_on:
- scheduler-db
networks:
- internal

# (re)define traefik proxy network
networks:
internal:
driver: overlay
traefik:
# defined elsewhere
external: true

volumes:
scheduler-dbdata:
name: scheduler-dbdata
driver_opts:
type: nfs
o: "nfsvers=4,addr=130.58.218.26,rw,nolock,soft"
device: ":/volumes/scheduler-dbdata"
2 changes: 1 addition & 1 deletion swatscraper
Submodule swatscraper updated 4 files
+1 −2 .gitignore
+1 −2 README.md
+15 −0 go.mod
+52 −0 go.sum