-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from swat-sccs/main
Merge Main into dcrepublic-dev
- Loading branch information
Showing
7 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
echo "Start cron" | ||
cron -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 * * * * /app/swatscraper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |