Skip to content

Commit 3d0b6ca

Browse files
committed
Merge branch 'main' into 21-sentry-auth-token
2 parents f2f02e6 + 4862ba5 commit 3d0b6ca

15 files changed

+996
-367
lines changed
File renamed without changes.

.github/workflows/build.yml

Lines changed: 23 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,24 @@
1-
# we are running the build in vercel now so we don't need this github action
2-
# commenting this out because this action kept failing on https://github.com/scientist-softserv/webstore/pull/268
3-
# TODO(alishaevn): figure out the sentry error if we switch from vercel to an in house deploy infrastructure
1+
name: "Build Docker Images"
2+
run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
inputs:
12+
debug_enabled:
13+
type: boolean
14+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
15+
required: false
16+
default: false
417

5-
# name: "Build Docker Images"
6-
# run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
7-
# on:
8-
# push:
9-
# branches:
10-
# - main
11-
# pull_request:
12-
# branches:
13-
# - main
14-
# workflow_dispatch:
15-
# inputs:
16-
# debug_enabled:
17-
# type: boolean
18-
# description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
19-
# required: false
20-
# default: false
21-
22-
# env:
23-
# REGISTRY: ghcr.io
24-
25-
# jobs:
26-
# build:
27-
# runs-on: ubuntu-latest
28-
# permissions:
29-
# contents: read
30-
# packages: write
31-
# steps:
32-
# - id: setup
33-
# name: Setup
34-
# uses: scientist-softserv/actions/[email protected]
35-
# with:
36-
# tag: ${{ inputs.tag }}
37-
# image_name: ${{ inputs.image_name }}
38-
# token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
39-
# - uses: actions/setup-node@v3
40-
# with:
41-
# registry-url: 'https://npm.pkg.github.com'
42-
# # Defaults to the user or organization that owns the workflow file
43-
# scope: '@scientist-softserv'
44-
# node-version-file: package.json
45-
# - name: GPR authToken
46-
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > $NPM_CONFIG_USERCONFIG
47-
# - name: GPR alias
48-
# run: echo "@scientist-softserv:registry=https://npm.pkg.github.com" >> $NPM_CONFIG_USERCONFIG
49-
# - run: yarn install
50-
# - run: yarn test
51-
52-
# - name: Login to GitHub Container Registry
53-
# uses: docker/login-action@v2
54-
# with:
55-
# registry: ${{ env.REGISTRY }}
56-
# username: ${{ github.actor }}
57-
# password: ${{ secrets.GITHUB_TOKEN }}
58-
59-
# - name: Retag action for Docker image
60-
# id: meta-docker-image
61-
# uses: docker/[email protected]
62-
# with:
63-
# images: |
64-
# name=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}
65-
# tags: |
66-
# type=raw,value=latest,enable={{is_default_branch}}
67-
68-
# - run: cp $NPM_CONFIG_USERCONFIG .npmrc; cat .npmrc
69-
70-
# - name: Build and push Docker image
71-
# uses: docker/build-push-action@v3
72-
# with:
73-
# cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
74-
# context: .
75-
# push: true
76-
# tags: |
77-
# ${{ steps.meta-docker-image.outputs.tags }}
78-
# ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
18+
jobs:
19+
build:
20+
uses: scientist-softserv/actions/.github/workflows/[email protected]
21+
secrets: inherit
22+
with:
23+
platforms: "linux/amd64"
24+
webTarget: web

.github/workflows/deploy.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# we are running the deploy through vercel now so we don't need this github action
2-
# TODO(alishaevn): fix any potential sentry error's if we switch from vercel to an in house deploy infrastructure
1+
# This webstore instance is currently deployed to: https://webstore-staging.vercel.app
2+
# In order to deploy via github actions instead, please update/confirm the following files:
3+
# - ops/production-deploy.tmpl.yaml
4+
# - ops/staging-deploy.tmpl.yaml
5+
# Next, uncomment the following lines
36

47
# name: "Deploy"
58
# run-name: Deploy (${{ github.ref_name }} -> ${{ inputs.environment }}) by @${{ github.actor }}
@@ -13,6 +16,7 @@
1316
# type: choice
1417
# options:
1518
# - staging
19+
# - production
1620
# debug_enabled:
1721
# type: boolean
1822
# description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
@@ -21,5 +25,5 @@
2125

2226
# jobs:
2327
# deploy:
24-
# uses: scientist-softserv/actions/.github/workflows/[email protected].10
28+
# uses: scientist-softserv/actions/.github/workflows/[email protected].16
2529
# secrets: inherit

.gitignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ node_modules/
44
# Next.js build output
55
.next
66

7-
# Where ENV secrets are stored. refer to the "Note" at the link below for details on the use of this file
8-
# https://nextjs.org/docs/basic-features/environment-variables#default-environment-variables
9-
.env.local
7+
# Where ENV secrets are stored. although NextJS uses `.env.local`
8+
# (https://nextjs.org/docs/basic-features/environment-variables#default-environment-variables), we are using `.env.development`
9+
# for consistency with other projects. this also ensures our CICD and docker processes work.
10+
.env.development
1011

1112
# we want the default npmrc but sometimes folks put in the gh tokens, don't commit those
1213
.npmrc
1314

1415
# Sentry
1516
.sentryclirc
17+
18+
# Emacs
19+
*.~undo-tree~

Dockerfile

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
1-
FROM node:18-alpine AS builder
2-
3-
ENV NODE_ENV=production \
4-
NEXT_TELEMETRY_DISABLED=1
5-
6-
WORKDIR /home/node/app
7-
8-
ADD . /home/node/app
9-
10-
# https://github.com/vercel/next.js/discussions/22149#discussioncomment-366180
11-
RUN yarn install && yarn build && npm prune --omit=dev
12-
13-
FROM node:18-alpine
1+
FROM node:18-alpine as web
142

153
ENV NODE_ENV="production" \
164
NEXT_TELEMETRY_DISABLED=1
175

186
WORKDIR /home/node/app
7+
RUN yarn add --dev eslint
198

20-
# https://javascript.plainenglish.io/reduce-docker-image-size-for-your-next-js-app-bcb65d322222
21-
# and
22-
# https://nextjs.org/docs/advanced-features/output-file-tracing
23-
COPY --from=builder /home/node/app/package.json /home/node/app/
24-
COPY --from=builder /home/node/app/yarn.lock /home/node/app/
25-
COPY --from=builder /home/node/app/next.config.js /home/node/app/
26-
COPY --from=builder /home/node/app/public /home/node/app/public
27-
COPY --from=builder /home/node/app/.next/standalone /home/node/app/
28-
COPY --from=builder /home/node/app/.next/static /home/node/app/.next/static
9+
COPY package.json yarn.lock /home/node/app/
10+
RUN yarn
2911

30-
CMD ["node", "server.js"]
12+
COPY . /home/node/app
13+
RUN yarn build
14+
CMD ["yarn", "start"]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ All API endpoints in this app require some form of authentication. A logged out
8484

8585
##### User Credentials
8686
``` bash
87-
# .env.local
87+
# .env.development
8888
NEXTAUTH_SECRET # create this by running `openssl rand -base64 32` in your terminal
8989
CLIENT_ID # retrieved from the provider storefront
9090
CLIENT_SECRET # retrieved from the provider storefront
@@ -104,7 +104,7 @@ curl -X POST -H 'Authorization: Basic THISISAREALLYLONGALPHANUMERICSTRING' -d 'g
104104
The curl command will return a JSON object that has an `access_token` property. Store the value of that property as shown below:
105105

106106
``` bash
107-
# .env.local
107+
# .env.development
108108
NEXT_PUBLIC_TOKEN
109109
```
110110

@@ -149,14 +149,14 @@ There are 2 types of Cypress tests, e2e & component.
149149
If you are creating an e2e test, it will live in the `cypress/e2e` directory. Component tests will need to be created in a directory called `cypress/component `
150150

151151
#### Setup your Cypress env variables
152-
- the Cypress suite requires an environment variable that should be stored in your `.env.local` and not committed to git.
152+
- the Cypress suite requires an environment variable that should be stored in your `.env.development` and not committed to git.
153153
- TEST_SESSION_COOKIE=
154154
- to get the value for this variable, open your browser to your running app at `localhost:3000`.
155155
- inspect the page
156156
- click the "Application" tab
157157
- click "Cookies"
158158
- find the value for `next-auth.session-token`
159-
- copy that value and paste it in the `TEST_SESSION_COOKIE` variable in your .env.local
159+
- copy that value and paste it in the `TEST_SESSION_COOKIE` variable in your .env.development
160160
- do not ever commit this value
161161
- this value will need to be updated whenever the cookie expires, approximately once per month
162162

bin/helm_deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ helm upgrade \
2929
--namespace="$namespace" \
3030
--create-namespace \
3131
"$release_name" \
32-
./charts/webstore
32+
./charts/webstore

bin/helm_deploy_local

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
# This script wraps up helm deployment. It is meant as a clear starting point for
4+
# commandline deployment or CI based deployment. It requires the following ENV vars be set
5+
#
6+
# CHART_VERSION: this is the version of the hyrax chart you want to deploy. default - 0.22.0
7+
# DEPLOY_IMAGE: this is the build image that runs the rails application. Typically this would run puma or passenger. eg: samvera/hyrax or ghcr.io/samvera/hyku. Defaults to gcrh.io/samvera/hyku
8+
# DEPLOY_TAG: name of of the tag you want to deploy for deploy image. eg: "latest" or "v3.0.1" or "f123asdf1". Defaults to latest
9+
# HELM_EXTRA_ARGS: any additional arguments you'd like passed to helm upgrade directly. can be blank.
10+
11+
if [ -z "$1" ] || [ -z "$2" ]
12+
then
13+
echo './bin/helm_deploy RELEASE_NAME NAMESPACE'
14+
exit 1
15+
fi
16+
release_name="${1}"
17+
namespace="${2}"
18+
19+
HELM_EXTRA_ARGS="${HELM_EXTRA_ARGS}:---values ops/production-deploy.yaml"
20+
DEPLOY_IMAGE="${DEPLOY_IMAGE:-ghcr.io/scientist-softserv/webstore}"
21+
DEPLOY_TAG="${DEPLOY_TAG:-latest}"
22+
23+
helm upgrade \
24+
--install \
25+
--atomic \
26+
--timeout 15m0s \
27+
--set image.repository="$DEPLOY_IMAGE" \
28+
--set image.tag="$DEPLOY_TAG" \
29+
--values ops/production-deploy.yaml \
30+
--namespace="$namespace" \
31+
--create-namespace \
32+
"$release_name" \
33+
./charts/webstore

charts/webstore/templates/deployment.yaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,47 @@ spec:
3434
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
3535
imagePullPolicy: {{ .Values.image.pullPolicy }}
3636
env:
37+
- name: CLIENT_SECRET
38+
value: "{{ .Values.clientSecret }}"
39+
- name: CLIENT_ID
40+
value: "{{ .Values.clientId }}"
41+
- name: NEXTAUTH_SECRET
42+
value: "{{ .Values.nextAuthSecret }}"
3743
- name: NEXTAUTH_URL
3844
value: "{{ .Values.nextAuthUrl }}"
39-
- name: NEXT_PUBLIC_PROVIDER_NAME
40-
value: "{{ .Values.providerName }}"
45+
- name: NEXT_PUBLIC_APP_BASE_URL
46+
value: "{{ .Values.appBaseUrl }}"
4147
- name: NEXT_PUBLIC_PROVIDER_ID
4248
value: "{{ .Values.providerId }}"
49+
- name: NEXT_PUBLIC_PROVIDER_NAME
50+
value: "{{ .Values.providerName }}"
4351
- name: NEXT_PUBLIC_SCIENTIST_API_VERSION
4452
value: "{{ .Values.scientistApiVersion }}"
4553
- name: NEXT_PUBLIC_TOKEN
4654
value: "{{ .Values.nextPublicToken }}"
47-
- name: NEXTAUTH_SECRET
48-
value: "{{ .Values.nextAuthSecret }}"
49-
- name: CLIENT_SECRET
50-
value: "{{ .Values.clientSecret }}"
51-
- name: CLIENT_ID
52-
value: "{{ .Values.clientId }}"
55+
- name: NEXT_PUBLIC_WEBHOOK_URL
56+
value: "{{ .Values.webhookUrl }}"
57+
- name: SENTRY_AUTH_TOKEN
58+
value: "{{ .Values.sentryAuthToken }}"
5359
- name: SENTRY_DSN
5460
value: "{{ .Values.sentryDsn }}"
61+
- name: SENTRY_ORG
62+
value: "{{ .Values.sentryOrg }}"
63+
- name: SENTRY_PROJECT
64+
value: "{{ .Values.sentryProject }}"
65+
- name: SENTRY_URL
66+
value: "{{ .Values.sentryUrl }}"
5567
ports:
5668
- name: http
5769
containerPort: {{ .Values.service.port }}
5870
protocol: TCP
5971
livenessProbe:
72+
initialDelaySeconds: 60
6073
httpGet:
6174
path: /
6275
port: http
6376
readinessProbe:
77+
initialDelaySeconds: 60
6478
httpGet:
6579
path: /
6680
port: http

charts/webstore/values.yaml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,27 @@ image:
88
repository: ghcr.io/scientist-softserv/webstore
99
pullPolicy: IfNotPresent
1010
# Overrides the image tag whose default is the chart appVersion.
11-
tag: "0.0.2"
11+
tag: '0.0.2'
1212

13+
appBaseUrl: ''
14+
clientId: ''
15+
clientSecret: ''
16+
fullnameOverride: ''
1317
imagePullSecrets: []
14-
nameOverride: ""
15-
fullnameOverride: ""
16-
apiTokenConfigSecret: ""
17-
nextAuthUrl: ""
18-
providerName: ""
19-
providerId: ""
20-
scientistApiVersion: ""
18+
nameOverride: ''
19+
nextAuthSecret: ''
20+
nextAuthUrl: ''
21+
nextPublicToken: ''
22+
providerId: ''
23+
providerName: ''
24+
replicaCount: ''
25+
scientistApiVersion: ''
26+
sentryAuthToken: ''
27+
sentryDsn: ''
28+
sentryOrg: ''
29+
sentryProject: ''
30+
sentryUrl: ''
31+
webhookUrl: ''
2132

2233
serviceAccount:
2334
# Specifies whether a service account should be created
@@ -26,7 +37,7 @@ serviceAccount:
2637
annotations: {}
2738
# The name of the service account to use.
2839
# If not set and create is true, a name is generated using the fullname template
29-
name: ""
40+
name: ''
3041

3142
podAnnotations: {}
3243

@@ -47,7 +58,7 @@ service:
4758

4859
ingress:
4960
enabled: false
50-
className: ""
61+
className: ''
5162
annotations: {}
5263
# kubernetes.io/ingress.class: nginx
5364
# kubernetes.io/tls-acme: "true"

0 commit comments

Comments
 (0)