Skip to content

Commit dffe29a

Browse files
authored
Merge pull request #75 from UTDNebula/fix-daily-runner
Add headless flag and documentation
2 parents 3c26acd + 91dd93e commit dffe29a

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
with:
4141
push: true
4242
tags: us-central1-docker.pkg.dev/api-tools-451421/runners/runner
43+
target: base
4344

4445
- name: Upload to daily dev job
4546
uses: google-github-actions/deploy-cloudrun@v2

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN make check
99
RUN make build
1010

1111
# Use a lightweight final image
12-
FROM debian:12-slim
12+
FROM debian:12-slim AS base
1313
WORKDIR /app
1414

1515
# Install gcloud CLI
@@ -20,12 +20,17 @@ RUN apt-get update && apt-get install -y google-cloud-sdk
2020

2121
# Install chromium
2222
RUN apt-get update && apt-get install -y chromium
23-
ENV CHROMIUM_BIN /usr/bin/chromium
24-
ENV GOOGLE_CHROME_BIN /usr/bin/chromium # Also set this for compatibility
23+
ENV CHROMIUM_BIN=/usr/bin/chromium
24+
ENV GOOGLE_CHROME_BIN=/usr/bin/chromium
2525

2626
# Copy build file from builder
2727
COPY --from=builder /app/api-tools /app/api-tools
28-
COPY runners /app/runners
2928

29+
# Copy setup and runner scripts for entrypoint
30+
COPY runners /app/runners
3031
RUN chmod +x /app/runners/setup.sh
3132
ENTRYPOINT ["/app/runners/setup.sh"]
33+
34+
# Optional .env copy for development
35+
FROM base AS dev
36+
COPY .env /app/.env

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,13 @@ To build the project, simply clone the repository and then either:
3535
- Run `build.bat` on Windows systems (unless you want to deal with getting `make` to work on Windows :P)
3636

3737
The build process will output an executable file named `api-tools`; this executable is the CLI and can be ran in your terminal!
38+
39+
#### Docker
40+
41+
Docker is used for automated running on Google Cloud Platform. More info [here](https://nebula-labs.atlassian.net/wiki/x/AYBjFw).
42+
43+
To build the container for local testing first make sure all scripts in the `runners` folder have LF line endings then run:
44+
```
45+
docker build --target dev -t my-runner:local .
46+
docker run --rm -e ENVIRONMENT=dev -e RUNNER_SCRIPT_NAME=daily.sh my-runner:local
47+
```

cloudbuild.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
steps:
2+
- name: 'gcr.io/cloud-builders/docker'
3+
args: ['build', '--target=base', '-t', 'us-central1-docker.pkg.dev/api-tools-451421/runners/runner', '.']
4+
images:
5+
- 'us-central1-docker.pkg.dev/api-tools-451421/runners/runner'

runners/daily.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# for daily tasks to run
44

55
# scrape, parse, and upload events
6-
./api-tools -scrape -mazevo -verbose
7-
./api-tools -parse -mazevo -verbose
8-
./api-tools -scrape -astra -verbose
9-
./api-tools -parse -astra -verbose
10-
./api-tools -upload -events -verbose
6+
./api-tools -headless -verbose -scrape -mazevo
7+
./api-tools -headless -verbose -parse -mazevo
8+
./api-tools -headless -verbose -scrape -astra
9+
./api-tools -headless -verbose -parse -astra
10+
./api-tools -headless -verbose -upload -events

runners/setup.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/bin/sh
22

3-
# auth with service account
4-
gcloud secrets versions access latest --secret="$SERVICE_ACCOUNT_SECRET_NAME" > service_account.json
5-
gcloud auth activate-service-account --key-file=service_account.json
6-
rm service_account.json
3+
if [ "$ENVIRONMENT" = "prod" ]; then
4+
# auth with service account
5+
gcloud secrets versions access latest --secret="$SERVICE_ACCOUNT_SECRET_NAME" > service_account.json
6+
gcloud auth activate-service-account --key-file=service_account.json
7+
rm service_account.json
78

8-
# use service account to access environment variables from GCP secrets, create .env
9-
gcloud secrets versions access latest --secret="$ENV_SECRET_NAME" > .env
9+
# use service account to access environment variables from GCP secrets, create .env
10+
gcloud secrets versions access latest --secret="$ENV_SECRET_NAME" > .env
11+
else
12+
echo "ENVIRONMENT is set to '$ENVIRONMENT'. Skipping env setup."
13+
fi
1014

1115
# run commands from the file path specified in the GCP run job's variable
1216
sh "/app/runners/$RUNNER_SCRIPT_NAME"

0 commit comments

Comments
 (0)