generated from data-team-uhn/cards-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ec560ba
Showing
20 changed files
with
881 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
* text=auto | ||
*.java text ident diff=java | ||
*.xml text ident diff=html | ||
*.vm text ident | ||
*.js text ident | ||
*.css text ident | ||
*.sh eol=lf ident | ||
*.bat eol=crlf ident |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Build | ||
target | ||
target-eclipse | ||
.mvnrepo | ||
|
||
# IDEA | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
atlassian-ide-plugin.xml | ||
|
||
# Solr locks | ||
write.lock | ||
|
||
# Eclipse | ||
.classpath | ||
.project | ||
.settings | ||
.checkstyle | ||
.fbprefs | ||
bin | ||
# Automatically generated by WTP | ||
**/src/main/java/META-INF/ | ||
**/src/test/java/META-INF/ | ||
**/src/META-INF/ | ||
|
||
# NetBeans | ||
nbproject | ||
|
||
# Visual Studio Code | ||
.vscode | ||
|
||
# Other | ||
*.log.* | ||
*.log | ||
.sonar-ide.properties | ||
.clover | ||
|
||
.DS_Store.DS_Store | ||
.DS_Store | ||
|
||
# Backup files created by some editors | ||
*~ | ||
|
||
# Eclipse build for war modules | ||
overlays | ||
|
||
# Node and friends | ||
node_modules | ||
**/src/main/frontend/node/ | ||
**/src/main/frontend/dist/ | ||
**/aggregated-frontend/src/main/frontend/src/ | ||
**/aggregated-frontend/src/main/frontend/webpack.config.js | ||
**/aggregated-frontend/src/main/frontend/package.json | ||
|
||
# Running instance | ||
/sling/ | ||
/.cards-data/ | ||
/distribution/sling/ | ||
/distribution/launcher/ | ||
/.metadata/ | ||
|
||
# Copy of source code needed for building JARs in a Docker container | ||
/distribution/COMPLETE_SOURCE_CODE.tar | ||
|
||
# SAML Keys | ||
samlKeystore.p12 | ||
|
||
# Form import byproducts | ||
/Utilities/FormImport/*.csv | ||
/Utilities/FormImport/*.json | ||
/Utilities/FormImport/*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Cards Project Template | ||
|
||
This is a template repository for CARDS-based projects. When creating a new project, use this repository as a template, then run `setup.sh` to customize it. | ||
|
||
After running the setup script, the codebase will be set up with backend, resources, and feature submodules for your project. | ||
|
||
You can add other resources, like questionnaires, in `resources/src/main/resources/SLING-INF/content/`, java code in `backend/src/main/java/`, or customize the other features to use in `docker_compose_env.json`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# $PROJECT_NAME$ | ||
|
||
## Building | ||
|
||
To build this project, if you didn't build the CARDS platform itself locally, you must first gather the _CARDS-platform_ Maven | ||
artifacts: | ||
|
||
```bash | ||
./get_cards_platform_jars.sh | ||
``` | ||
|
||
Then run: | ||
|
||
```bash | ||
mvn clean install -U | ||
``` | ||
|
||
### Building Docker Images | ||
|
||
Docker images for this project are built on top of a generic CARDS image. | ||
You can either download one from the github repository, or build a local image from source. | ||
In either case, the version of CARDS to use must match the version declared in the root `pom.xml` file as the `cards.version` property. | ||
|
||
There are two sets of maven build profiles you can choose from: | ||
- if you want to use a `local`, `published`, or `latest` image for the base CARDS project | ||
- and if you want to build a `production` or `development` image | ||
|
||
A development image will be slimmer, since it skips copying any of the built JARs into the Docker image, so it must be used on the same machine where it was built, using the local maven repository as a source for dependencies. | ||
Therefore, the resultant image should only be used with the `--dev_docker_image` and `--cards_generic_jars_repo` flags for `generate_compose_yaml.py`. | ||
This is useful for testing new code during development as it does not require a new Docker image to be built every time that code is changed. | ||
|
||
A production image will be self-contained, and can be started on any computer, even without access to internet. In this case, the base CARDS image you use must also be a production image. | ||
|
||
As for the base image to use, `local` will use a CARDS image built on the same computer, but with a version matching the `cards.version` property, e.g. `cards/cards:0.9.20`, | ||
`published` will use an image with a matching version fetched from our github package repository, e.g. `ghcr.io/data-team-uhn/cards:0.9.20`, | ||
and `latest` will use the latest image built locally, `cards/cards:latest`. | ||
If neither of these are right, you can either change the value to use in `docker/pom.xml`, or in `docker/Dockerfile`, | ||
or just once when building by overriding the `cardsBaseImage` maven parameter, e.g. `mvn install -P production -D cardsBaseImage=ghcr.io/data-team-uhn/cards:0.9.20_apple-cert`. | ||
The default is to use the `local` image. | ||
|
||
So, to build a development image based on the latest CARDS image, run: | ||
|
||
```bash | ||
mvn clean install -P development,latest | ||
``` | ||
|
||
To build a production image based on the corresponding published CARDS image, run: | ||
|
||
```bash | ||
mvn clean install -P production,published | ||
``` | ||
|
||
## Running | ||
|
||
### Production Mode | ||
|
||
#### Using Docker Compose | ||
|
||
Enter the main `cards-deploy-tool` repository (https://github.com/data-team-uhn/cards-deploy-tool) | ||
and start the project with: | ||
|
||
```bash | ||
python3 generate_compose_yaml.py --cards_docker_image cards/$PROJECT_CODENAME$:latest --oak_filesystem --composum | ||
docker-compose build | ||
docker-compose up -d | ||
``` | ||
|
||
$PROJECT_CODENAME$ will be available at http://localhost:8080 once it starts. | ||
|
||
### Development Mode | ||
|
||
#### Using `./start_cards.sh` | ||
|
||
Enter the main `cards` repository (https://github.com/data-team-uhn/cards) | ||
and build the generic CARDS platform with: | ||
|
||
```bash | ||
mvn clean install | ||
``` | ||
|
||
Then, start the project with (replace with the current version of this project): | ||
|
||
```bash | ||
PROJECT_VERSION=1.0.0-SNAPSHOT ./start_cards.sh --dev --project $PROJECT_CODENAME$ $ADDITIONAL_SLING_FEATURES$ | ||
``` | ||
|
||
$PROJECT_CODENAME$ will be available at http://localhost:8080 once it starts. | ||
|
||
#### Using Docker Compose | ||
|
||
Enter the main `cards-deploy-tool` repository (https://github.com/data-team-uhn/cards-deploy-tool) | ||
and start the project with: | ||
|
||
```bash | ||
python3 generate_compose_yaml.py --dev_docker_image --cards_generic_jars_repo /path/to/$PROJECT_CODENAME$/.cards-generic-mvnrepo --cards_docker_image cards/$PROJECT_CODENAME$:latest --oak_filesystem --composum | ||
docker-compose build | ||
docker-compose up -d | ||
``` | ||
|
||
$PROJECT_CODENAME$ will be available at http://localhost:8080 once it starts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2023 DATA @ UHN. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.uhndata.cards</groupId> | ||
<artifactId>$PROJECT_SHORTNAME$-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>$PROJECT_SHORTNAME$-backend</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>$PROJECT_NAME$ - Backend code</name> | ||
|
||
<build> | ||
<plugins> | ||
<!-- This is an OSGi bundle --> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# Start with the generic CARDS image | ||
# If you want to use the hosted version, or a specific version of cards, pass an argument like this to docker build: | ||
# --build-arg="GENERIC_CARDS_DOCKER_IMAGE=ghcr.io/data-team-uhn/cards:0.9.20_apple-cert" | ||
# --build-arg="GENERIC_CARDS_DOCKER_IMAGE=cards/cards:0.9.20" | ||
FROM ${cardsBaseImage} | ||
|
||
# Configure the image for this project | ||
RUN mkdir /external_project | ||
COPY project_code.txt /external_project | ||
COPY project_name.txt /external_project | ||
COPY docker_compose_env.json /external_project | ||
COPY project_logo.png /metadata/logo.png | ||
|
||
# Copy in the required JARs | ||
COPY .m2/repository /root/.m2/repository | ||
|
||
# Set the current project version | ||
ENV PROJECT_NAME=$PROJECT_CODENAME$ | ||
ENV PROJECT_VERSION=${project.version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"cardsinitial": [ | ||
{ | ||
"name": "ADDITIONAL_SLING_FEATURES", | ||
"value": "$ADDITIONAL_SLING_FEATURES$", | ||
"conditions": null | ||
}, | ||
{ | ||
"name": "PROJECT_NAME", | ||
"value": "$PROJECT_CODENAME$", | ||
"conditions": null | ||
} | ||
], | ||
"proxy": [ | ||
{ | ||
"name": "CARDS_APP_NAME", | ||
"value": "$PROJECT_NAME$", | ||
"conditions": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# Check that this Docker image is actually present on the build machine | ||
(docker image inspect cards/sling-feature-downloader >/dev/null 2>/dev/null) || { echo "Fail: Could not find the cards/sling-feature-downloader locally. Please get it from https://github.com/data-team-uhn/cards-sling-feature-downloader and build it. Exiting."; exit 1; } | ||
|
||
GROUP_NAME=$(cat ../feature/pom.xml | grep --max-count=1 '<groupId>' | cut '-d>' -f2 | cut '-d<' -f1) | ||
PROJECT_NAME=$(cat ../feature/pom.xml | grep --max-count=1 '^ <artifactId>' | cut '-d>' -f2 | cut '-d<' -f1) | ||
PROJECT_VERSION=$(cat ../pom.xml | grep --max-count=1 '^ <version>' | cut '-d>' -f2 | cut '-d<' -f1) | ||
|
||
mkdir -p .m2 | ||
|
||
# Add any packages that are required for running this project and are not included in the generic CARDS Docker image | ||
# to this local .m2 directory | ||
docker run \ | ||
--rm \ | ||
--user $UID:$(id -g) \ | ||
-v ${HOME}/.m2:/host_m2:ro \ | ||
-v $(realpath ../.cards-generic-mvnrepo):/cards-generic-mvnrepo:ro \ | ||
-v $(realpath .m2):/m2 \ | ||
-e MAVEN_FEATURE_NAME="mvn:${GROUP_NAME}/${PROJECT_NAME}/${PROJECT_VERSION}/slingosgifeature" \ | ||
-e MAVEN_REPO_URLS="file:///cards-generic-mvnrepo/repository,http://localhost:8000" \ | ||
--network none \ | ||
--entrypoint /bin/sh \ | ||
cards/sling-feature-downloader /download_single_feature_with_deps.sh |
Oops, something went wrong.