Skip to content

Commit

Permalink
Merge pull request #1 from scientist-softserv/build_work
Browse files Browse the repository at this point in the history
trying to get the build to work
  • Loading branch information
aprilrieger authored Aug 3, 2023
2 parents f73a959 + a2096f4 commit d38c105
Show file tree
Hide file tree
Showing 14 changed files with 282 additions and 145 deletions.
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
*.rdb
./artifacts
./chart
./coverage
./docker
./fcrepo
./importer
./log
./pg
./public/assets
./public/branding
./public/packs
./public/system
./public/uploads
./tmp
.coveralls.yml
.ebextensions
.fcrepo_wrapper
.hound.yml
.idea
.internal_test_app/*
.solr_wrapper

node_modules/*
solr/solr/*
fcrpo/*
pg/*
fits.log
ImageMagick*
.DS_Store
19 changes: 0 additions & 19 deletions .github/workflows/build-base.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/build-solr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ on:

jobs:
build:
uses: scientist-softserv/actions/.github/workflows/[email protected].14
uses: scientist-softserv/actions/.github/workflows/[email protected].15
secrets: inherit
with:
platforms: "linux/amd64"
solrTarget: hyku-solr
subdir: hyrax-webapp
7 changes: 3 additions & 4 deletions .github/workflows/build-test-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,24 @@ on:

jobs:
build:
uses: scientist-softserv/actions/.github/workflows/build.yaml@add_debugger
uses: scientist-softserv/actions/.github/workflows/build.yaml@v0.0.15
secrets: inherit
with:
platforms: 'linux/amd64'
webTarget: hyku-web
workerTarget: hyku-worker
subdir: hyrax-webapp

test:
needs: build
uses: scientist-softserv/actions/.github/workflows/test.yaml@add_debugger
uses: scientist-softserv/actions/.github/workflows/test.yaml@v0.0.15
with:
confdir: '/app/samvera/hyrax-webapp/solr/conf'
webTarget: hyku-web
workerTarget: hyku-worker

lint:
needs: build
uses: scientist-softserv/actions/.github/workflows/lint.yaml@add_debugger
uses: scientist-softserv/actions/.github/workflows/lint.yaml@v0.0.15
with:
webTarget: hyku-web
workerTarget: hyku-worker
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ on:

jobs:
deploy:
uses: scientist-softserv/actions/.github/workflows/[email protected].14
uses: scientist-softserv/actions/.github/workflows/[email protected].15
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
scratch.md
*~undo-tree~
.env.*
.DS_Store
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ghcr.io/samvera/hyku/base:latest as hyku-web
ARG APP_PATH
COPY --chown=1001:101 $APP_PATH/Gemfile* /app/samvera/hyrax-webapp/
RUN git config --global --add safe.directory /app/samvera && \
bundle install --jobs "$(nproc)"

COPY --chown=1001:101 $APP_PATH/bin/db-migrate-seed.sh /app/samvera/
# This is specifically NOT $APP_PATH but the parent directory
COPY --chown=1001:101 . /app/samvera

RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DB_URL='postgresql://fake' bundle exec rake assets:precompile && yarn install
CMD ./bin/web

FROM hyku-web as hyku-worker
CMD ./bin/worker
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ git push -u origin main
```

### Overrides
Before overriding anything, please think hard about whether what you are working on is a bug or feature that can apply to Hyku itself. If it is, please make a branch in your Hyku checkout (`./hyrax-webapp`) and do the work there. [See here](https://github.com/samvera-labs/hyku_knapsack/wiki/Hyku-Branches) for more information about working with Hyku branches in your Knapsack

Adding decorators to override features is fairly simple. We do recommend some best practices [found here](https://github.com/samvera-labs/hyku_knapsack/wiki/Decorators-and-Overrides)

Any file with `_decorator.rb` in the app or lib directory will automatically be loaded along with any classes in the app directory.
Expand Down
28 changes: 28 additions & 0 deletions bin/checkout_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Save the current branch name
current_branch=$(git rev-parse HEAD)

# Fetch any updates from the origin
if $(git rev-parse --is-shallow-repository); then
git fetch --unshallow -a origin
else
git fetch -a origin
fi

# Loop through all remote branches
for branch in $(git branch -r | grep -v '\->'); do
# Checkout each branch
if [[ $branch == *origin* ]]; then
branch_name="${branch#origin/}"
echo "Checking out $branch_name branch..."
git checkout $branch_name
else
echo "$branch is not from the origin"
fi
done

# Switch back to the original branch
git checkout $current_branch

echo "Operation complete, returned to $current_branch"
43 changes: 43 additions & 0 deletions bin/helm_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

# This script wraps up helm deployment. It is meant as a clear starting point for
# commandline deployment or CI based deployment. It requires the following ENV vars be set
#
# CHART_VERSION: this is the version of the hyrax chart you want to deploy. default - 0.22.0
# 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
# WORKER_IMAGE: this is the worker target, usually built from the same Dockerfile as DEPLOY_IMAGE. eg: samvera/hyrax/worker or ghcr.io/samvera/hyku/worker. Defaults to gcrh.io/samvera/hyku/worker
# 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
# WORKER_TAG: name of of the tag you want to deploy for deploy image. eg: "latest" or "v3.0.1" or "f123asdf1". Defaults to DEPLOY_TAG
# HELM_EXTRA_ARGS: any additional arguments you'd like passed to helm upgrade directly. can be blank.

if [ -z "$1" ] || [ -z "$2" ]
then
echo './bin/deploy RELEASE_NAME NAMESPACE'
exit 1
fi
release_name="${1//_/-}"
namespace="${2//_/-}"

DEPLOY_IMAGE="${DEPLOY_IMAGE:-ghcr.io/samvera/hyku}"
WORKER_IMAGE="${WORKER_IMAGE:-ghcr.io/samvera/hyku/worker}"
DEPLOY_TAG="${DEPLOY_TAG:-latest}"
WORKER_TAG="${WORKER_TAG:-$DEPLOY_TAG}"
echo $DEPLOY_TAG

CHART_VERSION="${CHART_VERSION:-2.0.0}"
helm pull --untar oci://ghcr.io/samvera/charts/hyrax --version $CHART_VERSION
helm repo update

helm upgrade \
--install \
--atomic \
--timeout 15m0s \
--set image.repository="$DEPLOY_IMAGE" \
--set image.tag="$DEPLOY_TAG" \
--set worker.image.repository="$WORKER_IMAGE" \
--set worker.image.tag="$DEPLOY_TAG" \
$HELM_EXTRA_ARGS \
--namespace="$namespace" \
--create-namespace \
"$release_name" \
hyrax
43 changes: 33 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
version: '3.8'
x-app: &app
build:
context: .
target: hyku-web
cache_from:
- ghcr.io/samvera/hyku/base:latest
- ghcr.io/scientist-softserv/hykuup_knapsack:latest
args:
BUILDKIT_INLINE_CACHE: 1
APP_PATH: ./hyrax-webapp
image: ghcr.io/scientist-softserv/hykuup_knapsack:${TAG:-latest}
environment:
# This line is what makes the knapsack include use the local code instead of the remote gem
- BUNDLE_LOCAL__HYKU_KNAPSACK=/app/samvera
- BUNDLE_DISABLE_LOCAL_BRANCH_CHECK=true
volumes:
- node_modules:/app/samvera/hyrax-webapp/node_modules:cached
- uploads:/app/samvera/hyrax-webapp/public/uploads:cached
- assets:/app/samvera/hyrax-webapp/public/assets:cached
- cache:/app/samvera/hyrax-webapp/tmp/cache:cached
- .:/app/samvera

volumes:
assets:
Expand Down Expand Up @@ -36,26 +57,28 @@ services:
file: hyrax-webapp/docker-compose.yml
service: db

base:
extends:
file: hyrax-webapp/docker-compose.yml
service: web
image: ghcr.io/samvera/hyku/base:${TAG:-latest}

web:
<<: *app
extends:
file: hyrax-webapp/docker-compose.yml
service: web
# command left commented for situations where the Gemfile.lock needs to be updated before the app starts
image: ghcr.io/scientist-softserv/hykuup_knapsack:${TAG:-latest}
command: bash -l -c "bundle && ./bin/web"
# command: bash -l -c "bundle && ./bin/web"
environment:
# This line is what makes the knapsack include use the local code instead of the remote gem
- BUNDLE_LOCAL__HYKU_KNAPSACK=/app/samvera
- BUNDLE_DISABLE_LOCAL_BRANCH_CHECK=true
- VIRTUAL_PORT=3000
- VIRTUAL_HOST=.hyku.test
volumes:
- node_modules:/app/samvera/hyrax-webapp/node_modules:cached
- uploads:/app/samvera/hyrax-webapp/public/uploads:cached
- assets:/app/samvera/hyrax-webapp/public/assets:cached
- cache:/app/samvera/hyrax-webapp/tmp/cache:cached
- .:/app/samvera

worker:
<<: *app
extends:
file: hyrax-webapp/docker-compose.yml
service: worker
Expand All @@ -68,18 +91,18 @@ services:
- .:/app/samvera

check_volumes:
<<: *app
extends:
file: hyrax-webapp/docker-compose.yml
service: check_volumes

initialize_app:
<<: *app
extends:
file: hyrax-webapp/docker-compose.yml
service: initialize_app
# command left commented for situations where the Gemfile.lock needs to be updated before the app starts
command:
- >
bundle &&
solrcloud-upload-configset.sh /app/samvera/hyrax-webapp/solr/conf &&
solrcloud-assign-configset.sh &&
SOLR_COLLECTION_NAME=hydra-test solrcloud-assign-configset.sh &&
Expand Down
Loading

0 comments on commit d38c105

Please sign in to comment.