Skip to content

Commit 692439c

Browse files
authored
Merge pull request #161 from CodeForPhilly/157-offline-dev
2 parents 1148dfb + da2a8d9 commit 692439c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+683
-491
lines changed

.devboxrc.example

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Commands you put here will run every time you enter the `devbox shell` or
2+
# run other devbox commands (like `devbox run` or `devbox services`).
3+
4+
# IMPORTANT:
5+
# - don't use this file for environment variables; use .env instead.
6+
# - `devbox services` runs in a basic sh shell, so only put POSIX-compliant
7+
# shell commands here (e.g. no bash-specific syntax) (unless you check for bash).
8+
9+
10+
# Tab completion for tools managed by devbox
11+
# if [ -n "$BASH_VERSION" ]; then
12+
# eval "$(quarkus completion)"
13+
14+
# Some tools install their bash completions to this directory
15+
# if [ -d .devbox/nix/profile/default/share/bash-completion/completions ]; then
16+
# for completion in .devbox/nix/profile/default/share/bash-completion/completions/*; do
17+
# [ -f "$completion" ] && source "$completion"
18+
# done
19+
# fi
20+
21+
# NOTE: for tab completion of devbox itself, put the following in your ~/.bashrc, etc:
22+
# source <(devbox completion bash)
23+
# fi
24+
25+
26+
# Disable or workaround tools that might interfere with devbox
27+
# command -v mise >/dev/null && mise deactivate # interferes with PATH
28+
29+
30+
# Project-specific aliases
31+
# alias dup="devbox services up"

.devcontainer/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM jetpackio/devbox:latest
2+
3+
# Installing your devbox project
4+
WORKDIR /code
5+
USER root:root
6+
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
7+
USER ${DEVBOX_USER}:${DEVBOX_USER}
8+
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
9+
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
10+
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} .env.example .env
11+
12+
13+
RUN devbox run -- echo "Installed Packages." && nix-store --gc && nix-store --optimise
14+
15+
RUN devbox shellenv --init-hook >> ~/.profile

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Devbox Remote Container",
3+
"build": {
4+
"dockerfile": "./Dockerfile",
5+
"context": ".."
6+
},
7+
"postCreateCommand": "bin/ensure-root-env-file && devbox run setup",
8+
"customizations": {
9+
"vscode": {
10+
"settings": {},
11+
"extensions": [
12+
"jetpack-io.devbox"
13+
]
14+
}
15+
},
16+
"remoteUser": "devbox"
17+
}

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
QUARKUS_GOOGLE_CLOUD_PROJECT_ID="demo-bdt-dev"
2+
QUARKUS_GOOGLE_CLOUD_FIREBASE_AUTH_EMULATOR_HOST="localhost:9099"
3+
QUARKUS_GOOGLE_CLOUD_STORAGE_HOST_OVERRIDE="http://127.0.0.1:9199"
4+
GCS_BUCKET_NAME="demo-bdt-dev.appspot.com"
5+
FIRESTORE_EMULATOR_HOST="127.0.0.1:8080"
6+

.envrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

.firebaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
}
1616
},
1717
"etags": {}
18-
}
18+
}
Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
1-
# This workflow build and push a Docker container to Google Artifact Registry
2-
# and deploy it on Cloud Run when a commit is pushed to the "main"
3-
# branch.
4-
#
5-
# To configure this workflow:
6-
#
7-
# 1. Enable the following Google Cloud APIs:
8-
#
9-
# - Artifact Registry (artifactregistry.googleapis.com)
10-
# - Cloud Run (run.googleapis.com)
11-
# - IAM Credentials API (iamcredentials.googleapis.com)
12-
#
13-
# You can learn more about enabling APIs at
14-
# https://support.google.com/googleapi/answer/6158841.
15-
#
16-
# 2. Create and configure a Workload Identity Provider for GitHub:
17-
# https://github.com/google-github-actions/auth#preferred-direct-workload-identity-federation.
18-
#
19-
# Depending on how you authenticate, you will need to grant an IAM principal
20-
# permissions on Google Cloud:
21-
#
22-
# - Artifact Registry Administrator (roles/artifactregistry.admin)
23-
# - Cloud Run Developer (roles/run.developer)
24-
#
25-
# You can learn more about setting IAM permissions at
26-
# https://cloud.google.com/iam/docs/manage-access-other-resources
27-
#
28-
# 3. Change the values in the "env" block to match your values.
1+
# This workflow uses devbox for dependency management and builds/deploys the builder API
2+
# to Cloud Run when a commit is pushed to the "main" branch.
293

30-
name: 'Build and Deploy to Cloud Run'
4+
name: 'Build and Deploy Builder API to Cloud Run'
315

326
on:
337
push:
348
branches:
359
- main
3610
paths:
3711
- 'builder-api/**'
12+
- 'devbox.json'
13+
- 'devbox.lock'
3814

3915
env:
4016
PROJECT_ID: 'benefit-decision-toolkit-play'
@@ -53,43 +29,39 @@ jobs:
5329

5430
steps:
5531
- name: 'Checkout'
56-
uses: 'actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332' # actions/checkout@v4
57-
58-
59-
# Configure Workload Identity Federation and generate an access token.
60-
#
61-
# See https://github.com/google-github-actions/auth for more options,
62-
# including authenticating via a JSON credentials file.
32+
uses: 'actions/checkout@v4'
33+
34+
# Devbox needs a .env file to exist, even if it's empty
35+
# TODO: Make this useful in this and other workflows by just consolidating env vars
36+
# here (so that we don't need to manage multiple places)
37+
- name: 'Create .env file'
38+
run: touch .env
39+
40+
# Setup devbox which includes all our dependencies: Maven, JDK 21, Quarkus, etc.
41+
- name: 'Install devbox'
42+
uses: 'jetify-com/[email protected]'
43+
with:
44+
enable-cache: true
45+
46+
# Configure Workload Identity Federation and generate an access token
6347
- id: 'auth'
6448
name: 'Authenticate to Google Cloud'
6549
uses: 'google-github-actions/auth@v2'
6650
with:
6751
workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}'
6852
service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
6953
project_id: ${{ env.PROJECT_ID }}
70-
71-
- name: 'Set up Cloud SDK'
72-
uses: 'google-github-actions/setup-gcloud@v2'
73-
74-
# BEGIN - Docker auth and build
7554

76-
# Configure Docker to use gcloud as a credential helper
55+
# Configure Docker to use gcloud as a credential helper (using devbox gcloud)
7756
- name: 'Configure Docker'
7857
run: |
79-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
80-
81-
# Download Java version
82-
- name: Set up Java 21
83-
uses: actions/setup-java@v3
84-
with:
85-
distribution: temurin
86-
java-version: 21
58+
devbox run -- gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
8759
88-
# Build the Quarkus app with Maven
60+
# Build the Quarkus app with Maven using devbox environment
8961
- name: 'Build Quarkus App'
9062
working-directory: builder-api
9163
run: |
92-
./mvnw package -DskipTests
64+
devbox run build-builder-api-ci
9365
9466
- name: 'Build and Push Container'
9567
working-directory: builder-api
@@ -99,21 +71,18 @@ jobs:
9971
docker push "${DOCKER_TAG}"
10072
10173
- name: 'Deploy to Cloud Run'
102-
103-
# END - Docker auth and build
104-
105-
uses: 'google-github-actions/deploy-cloudrun@33553064113a37d688aa6937bacbdc481580be17' # google-github-actions/deploy-cloudrun@v2
74+
uses: 'google-github-actions/deploy-cloudrun@v2'
10675
with:
10776
service: '${{ env.API_NAME }}'
10877
region: '${{ env.REGION }}'
109-
# NOTE: If using a pre-built image, update the image name below:
110-
11178
image: '${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.API_NAME }}:latest'
11279
service_account: 'builder-api-service-account@${{ env.PROJECT_ID }}.iam.gserviceaccount.com'
11380
flags: '--allow-unauthenticated --max-instances=2'
81+
env_vars: |
82+
QUARKUS_GOOGLE_CLOUD_PROJECT_ID=${{ env.PROJECT_ID }}
83+
GCS_BUCKET_NAME=${{ env.PROJECT_ID }}.firebasestorage.app
11484
11585
# If required, use the Cloud Run URL output in later steps
11686
- name: 'Show output'
117-
run: |2-
118-
119-
echo ${{ steps.deploy.outputs.url }}
87+
run: |
88+
echo ${{ steps.deploy.outputs.url }}
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
name: Build and Deploy to Firebase Hosting
1+
# This workflow uses devbox for dependency management and builds/deploys the builder frontend
2+
# to Firebase Hosting when a commit is pushed to the "main" branch.
3+
4+
name: 'Build and Deploy Builder Frontend to Firebase Hosting'
25

36
on:
47
push:
58
branches:
69
- main
710
paths:
811
- 'builder-frontend/**'
12+
- 'devbox.json'
13+
- 'devbox.lock'
914

1015
env:
1116
PROJECT_ID: 'benefit-decision-toolkit-play'
@@ -24,10 +29,17 @@ jobs:
2429
- name: Checkout repository
2530
uses: actions/checkout@v4
2631

27-
# Configure Workload Identity Federation and generate an access token.
28-
#
29-
# See https://github.com/google-github-actions/auth for more options,
30-
# including authenticating via a JSON credentials file.
32+
# Devbox needs a .env file to exist, even if it's empty
33+
- name: 'Create .env file'
34+
run: touch .env
35+
36+
# Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK
37+
- name: 'Install devbox'
38+
uses: 'jetify-com/[email protected]'
39+
with:
40+
enable-cache: true
41+
42+
# Configure Workload Identity Federation and generate an access token
3143
- id: 'auth'
3244
name: 'Authenticate to Google Cloud'
3345
uses: 'google-github-actions/auth@v2'
@@ -36,28 +48,21 @@ jobs:
3648
service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
3749
project_id: ${{ env.PROJECT_ID }}
3850

39-
- name: Setup Node.js
40-
uses: actions/setup-node@v4
41-
with:
42-
node-version: '18'
43-
4451
- name: Cache node modules
45-
uses: actions/cache@v3
52+
uses: actions/cache@v4
4653
with:
4754
path: builder-frontend/node_modules
4855
key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }}
4956
restore-keys: |
5057
${{ runner.os }}-node-
51-
cache: 'npm'
52-
cache-dependency-path: 'builder-frontend/package-lock.json'
5358
5459
- name: Install dependencies
5560
working-directory: builder-frontend
56-
run: npm ci
61+
run: devbox run install-builder-frontend-ci
5762

5863
- name: Build application
5964
working-directory: builder-frontend
60-
run: npm run build
65+
run: devbox run build-builder-frontend-ci
6166
env:
6267
VITE_API_URL: ${{ secrets.VITE_API_URL}}
6368
VITE_SCREENER_BASE_URL: ${{ secrets.VITE_SCREENER_BASE_URL}}
@@ -69,8 +74,5 @@ jobs:
6974
VITE_APP_ID: ${{ secrets.VITE_APP_ID}}
7075
VITE_MEASUREMENT_ID: ${{ secrets.VITE_MEASUREMENT_ID}}
7176

72-
- name: Install Firebase CLI
73-
run: npm install -g firebase-tools
74-
7577
- name: Deploy to Firebase Hosting
76-
run: firebase deploy --only hosting:builder-frontend
78+
run: devbox run -- firebase deploy --only hosting:builder-frontend

0 commit comments

Comments
 (0)