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

Kubernetes Builds #373

Closed
wants to merge 102 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
c372167
Bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 11, 2023
e4706dd
Bump word-wrap from 1.2.3 to 1.2.4
dependabot[bot] Jul 19, 2023
6b36118
[C] Github workflows have NOIRLab releases endpoint env vars
Aug 3, 2023
4a0dfd4
[B] Revert to v1 NOIRLab releases endpoint
Aug 3, 2023
cc76f0e
[F] Basic EFD fetch POC in SummitStatus component
May 30, 2023
d33d9e2
[C] Proxy for USDF CORS issue from local
Jun 6, 2023
d44dea1
[C] Change range to queryable timeframe
Jun 13, 2023
d95b55b
[F] SummitData provider
alexgoff Jun 14, 2023
47aad98
[F] SummitData provider
alexgoff Jun 14, 2023
107746d
[C] set up individual queries
alexgoff Jun 15, 2023
e184449
[C] parallel data query requests
alexgoff Jun 16, 2023
bb21010
[C] linting
alexgoff Jun 20, 2023
f68cd60
[C] remove commented code
alexgoff Jun 20, 2023
8f9723d
[C] update path
alexgoff Jun 21, 2023
2a4da5a
[F] Basic EFD fetch POC in SummitStatus component
May 30, 2023
b837a96
[F] SummitData provider
alexgoff Jun 14, 2023
66f4f12
[F] SummitStatusModal
alexgoff Jun 21, 2023
2dfe729
[C] finish widget sections
alexgoff Jun 21, 2023
43123e6
[C] mergey merge
alexgoff Jun 21, 2023
bf85e83
[C] lint
alexgoff Jun 21, 2023
d5311a0
[C] add some undefined resiliency
alexgoff Jun 21, 2023
5bbadf9
[C] track individual loading states
alexgoff Jun 22, 2023
7e78ddb
[C] fixes and local time
alexgoff Jun 22, 2023
debca18
[C] remove extra prop
alexgoff Jun 22, 2023
87fbd3b
[C] set up astroweather
alexgoff Jun 22, 2023
18a2059
[F] lunar phase setup
alexgoff Jun 23, 2023
8e02ca3
[C] condense props and labels
alexgoff Jun 23, 2023
27b28a6
[F] daylight widget
alexgoff Jun 26, 2023
d431d04
[C] finish up daylight widget
alexgoff Jun 27, 2023
80088c4
[C] responsive styling fixes
alexgoff Jun 29, 2023
80d6912
[C] remove max-width
alexgoff Jun 29, 2023
347d638
[C] more responsive work
alexgoff Jun 29, 2023
963b0d2
[F] efd internal API enpoint + hooks fetching
Jun 26, 2023
873cf80
[B] Correct EFD response format + useEfd no longer async
Jul 11, 2023
f9a77a6
[C] Proxy for USDF CORS issue from local
Jun 6, 2023
503659b
[F] daylight widget
alexgoff Jun 26, 2023
0796b4a
[C] responsive styling fixes
alexgoff Jun 29, 2023
9ed0a7e
[F] Moonrise widget
alexgoff Jul 5, 2023
1baf351
[C] resolve merge
alexgoff Jul 17, 2023
7f33e7d
[C] Proxy for USDF CORS issue from local
Jun 6, 2023
f9ac4ce
[F] daylight widget
alexgoff Jun 26, 2023
eba3b25
[F] Moonrise widget
alexgoff Jul 6, 2023
5c779be
[C] pull in suncalc
alexgoff Jul 17, 2023
4909803
[C] move timezone offset inside of lib
alexgoff Jul 17, 2023
7f59ffc
[C] remove extra method
alexgoff Jul 17, 2023
dbc918c
[C] Proxy for USDF CORS issue from local
Jun 6, 2023
d291a70
[F] SummitStatusModal
alexgoff Jun 21, 2023
8d7d107
[C] set up astroweather
alexgoff Jun 22, 2023
682307d
[F] daylight widget
alexgoff Jun 26, 2023
c3ba25f
[F] Moonrise widget
alexgoff Jul 6, 2023
41d2d0b
[C] invert Daylight widget to center night
alexgoff Jul 7, 2023
ee45263
rebase
alexgoff Jul 19, 2023
072794a
rebase
alexgoff Jul 19, 2023
5ecd224
lint
alexgoff Jul 19, 2023
8353f42
[C] remove suncalc again
alexgoff Jul 19, 2023
b44f9c7
[F] Zenith and Azimuth widgets
alexgoff Jul 28, 2023
4e03b31
[C] add shutter speed and slew speed
alexgoff Jul 31, 2023
aa4cac8
[C] adjust padding
alexgoff Aug 1, 2023
9614ffd
[C] some cleanup
alexgoff Aug 1, 2023
d4f896b
[C] fix daytime showing incorrectly between 12-1pm
alexgoff Aug 1, 2023
e56bdcd
[F] Dewpoint
alexgoff Aug 3, 2023
be493fc
[C] Finalize dewpoint
alexgoff Aug 3, 2023
a2db59e
[C] SVG cross browser compat
alexgoff Aug 9, 2023
002575c
[C] try to set up demo
alexgoff Aug 7, 2023
3f2b3ce
[C] try other fixes
alexgoff Aug 7, 2023
61fbc52
[C] Redis setup complete
alexgoff Aug 8, 2023
202ed19
[C] remove Number constructors
alexgoff Aug 8, 2023
d45af51
[C] update components to use EFD mappings
alexgoff Aug 10, 2023
bbf2654
[C] move astroweather calcs to endpoint
alexgoff Aug 4, 2023
063f9b8
[C] integrate astroweather with efd
alexgoff Aug 10, 2023
48c17e8
[C] Docker build args include EDC EFD API url
Aug 21, 2023
980fa25
[B] VideoBlock has responsive dimensions
Aug 29, 2023
fe30f64
[B] Correct int domain env vars
Aug 29, 2023
cc4f5ed
[F] Only show hourly weather for current calendar day
Aug 22, 2023
f114cb0
[F] SummitStatus uses hasura graphQL endpoint
Aug 22, 2023
3d37117
[C] Add editor config for IDE code styles
Aug 24, 2023
87fb00f
[C] ENV VARS include Hasura secret
Aug 29, 2023
08f7c36
add build and push workflow
jtrouth Sep 7, 2023
e2078cf
Update Dockerfile for k8s
jtrouth Sep 7, 2023
18cc16b
update trigger branches
jtrouth Sep 7, 2023
bb31210
[F] Callouts use new DAM plugin
Nov 21, 2023
c4099a3
[F] ImageGrid content block
Sep 13, 2023
65ca339
[B] Search results only return entries with uris
Sep 14, 2023
93e6d9f
[B] Locale string Rubin Voices typo fixed
Oct 23, 2023
6ed171b
[F] Survey Sparrow script
Oct 23, 2023
ba7b1f9
[F] Rockman pop up uses site language
Nov 21, 2023
ce60bab
[F] Callouts use new DAM plugin
Nov 21, 2023
1d1be4e
Update Dockerfile for k8s
jtrouth Sep 7, 2023
1cdb37e
fix tags
jtrouth Dec 19, 2023
e9b475f
[F] Survey Sparrow script
Oct 23, 2023
d5cce29
Update Dockerfile for k8s
jtrouth Sep 7, 2023
c17c6dc
[F] Survey Sparrow script
Oct 23, 2023
53d61e6
Merge branch 'develop' into k8s-build-updates
jtrouth Dec 19, 2023
8351cb8
[F] Plausible rolls up stats to individual & aggregate dashboard
Dec 28, 2023
f4ea375
Update workflow
jtrouth Dec 29, 2023
2015266
Merge remote-tracking branch 'origin/master' into k8s-build-updates
jtrouth Jan 3, 2024
4aca13d
update
jtrouth Jan 3, 2024
83c2344
update
jtrouth Jan 3, 2024
4ab7db9
update
jtrouth Jan 3, 2024
57d3c7c
Merge remote-tracking branch 'origin/develop' into k8s-build-updates
jtrouth Jan 3, 2024
ec09046
update
jtrouth Jan 3, 2024
ab32917
Merge remote-tracking branch 'origin/develop' into k8s-build-updates
jtrouth Mar 4, 2024
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
159 changes: 159 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Build, Push, and Deploy
concurrency:
group: $${{ github.ref_name }}

on:
push:
branches:
- 'develop'
- 'master'
tags:
- 'v.*'
pull_request:
types:
- 'opened'
- 'synchronize'
- 'reopened'
- 'closed'
branches:
- 'develop'
- 'master'

jobs:
build:
name: Build Container Image
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.deploy-info.outputs.image_tag }}
image_name: ${{ steps.deploy-info.outputs.image_name }}
environment_name: ${{ steps.deploy-info.outputs.environment_name }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
gcr.io/skyviewer/rubinobs-client,enable=${{ github.ref != 'master' && github.ref_type != 'tag' && github.base_ref == 'develop' }}
gcr.io/edc-int-6c5e/rubinobs-client,enable=${{ github.ref == 'master' || github.base_ref == 'master'}}
gcr.io/edc-prod-eef0/rubinobs-client,enable=${{ github.ref_type == 'tag'}}
flavor: |
latest=${{ github.event_name == 'push'}}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Parse deployment info
id: deploy-info
run: |
# Determine environment to deploy to
if ${{ github.ref != 'master' && github.ref_type != 'tag' && github.base_ref == 'develop' }}; then
environment_name="dev"
credentials_json='${{ secrets.DEV_SA_KEY }}'
elif ${{ github.ref == 'master' || github.base_ref == 'master'}}; then
environment_name="int"
credentials_json='${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }}'
elif ${{ github.ref_type == 'tag'}}; then
environment_name="prod"
credentials_json='${{ secrets.PIPELINE_EPO_PROD_PROJECT }}'
else
environment_name=""
credentials_json=""
fi
echo environment_name=$environment_name >> "$GITHUB_OUTPUT"
echo credentials_json=$credentials_json >> "$GITHUB_OUTPUT"

# Parse container image tag to deploy
full_tag=$(echo "$DOCKER_METADATA_OUTPUT_JSON" | jq -r '.tags[] | limit(1; select(. | test(":sha-|:v.")))')
echo "Will use tag \"$full_tag\" for deployment."
echo image_tag=$(echo "$full_tag" | cut -f2 -d:) >> "$GITHUB_OUTPUT"
echo image_name=$(echo "$full_tag" | cut -f1 -d:) >> "$GITHUB_OUTPUT"
echo full_tag=$full_tag >> "$GITHUB_OUTPUT"

-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GCP
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ steps.deploy-info.outputs.credentials_json }}
-
name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
-
run: gcloud --quiet auth configure-docker
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: |
type=gha
cache-from: |
type=gha
build-args: |
RUN_BUILD=false
-
name: Summary
run: |
cat <<-EOT >> "$GITHUB_STEP_SUMMARY"
# Container Build Completed

## Tags
${{ steps.meta.outputs.tags }}
EOT

deploy:
name: Trigger deploy to ${{ needs.build.outputs.environment_name }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Generate Webhook Payload
id: payload
run: |-
PARAMETERS=(
client.image.tag=${{ needs.build.outputs.image_tag }}
client.image.repository=${{ needs.build.outputs.image_name }}
)
DATA="{
\"app_name\": \"rubinobs-site\",
\"environment_name\": \"${{ needs.build.outputs.environment_name }}\",
\"parameters\": $(jq -c -n '$ARGS.positional' --args ${PARAMETERS[@]})
}"
echo "data=$(echo $DATA | jq -rc '.')" >> "$GITHUB_OUTPUT"
- uses: lasith-kg/[email protected]
id: dispatch
name: Trigger Deployment
with:
dispatch-method: repository_dispatch
repo: edc-deploy
owner: lsst-epo
event-type: app_update_values
token: ${{ secrets.EDC_DEPLOY_GITHUB_TOKEN_FOR_REST_API }}
workflow-inputs: ${{ steps.payload.outputs.data }}
discover: true
- name: Await Run ID ${{ steps.dispatch.outputs.run-id }}
uses: Codex-/[email protected]
with:
token: ${{ secrets.EDC_DEPLOY_GITHUB_TOKEN_FOR_REST_API }}
repo: edc-deploy
owner: lsst-epo
run_id: ${{ steps.dispatch.outputs.run-id }}
run_timeout_seconds: 1500
66 changes: 50 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# This file is based on the official Next.js Docker example. https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
FROM node:18-alpine AS base

# Rebuild the source code only when needed
FROM node:16-alpine AS builder
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY . /app

RUN apk add --no-cache libc6-compat git
RUN yarn install --frozen-lockfile
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

ARG NEXT_PUBLIC_API_URL=https://api.rubinobs.org/api
ARG EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger
Expand All @@ -19,24 +33,44 @@ ARG NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql
ARG NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7
ARG NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback`

RUN npx browserslist@latest --update-db && yarn static:build
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV EDC_LOGGER_API_URL=$EDC_LOGGER_API_URL
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_GOOGLE_APP_ID=$NEXT_PUBLIC_GOOGLE_APP_ID
ENV NEXT_PUBLIC_CONTACT_FORM_POST_URL=$NEXT_PUBLIC_CONTACT_FORM_POST_URL
ENV NEXT_PUBLIC_PLAUSIBLE_DOMAIN=$NEXT_PUBLIC_PLAUSIBLE_DOMAIN
ENV CLOUD_ENV=$CLOUD_ENV

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

ARG RUN_BUILD="true"
ENV RUN_BUILD=${RUN_BUILD}

RUN if $RUN_BUILD;then yarn static:build;fi

# If using npm comment out above and use below instead
# RUN npm run build

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
FROM base AS runner
WORKDIR /app

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder --chown=nextjs:nodejs /app/ ./

USER nextjs

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1

EXPOSE 8080

CMD ["yarn", "start"]
ENV PORT 8080

CMD ["yarn", "start"]
Loading