Skip to content

Commit

Permalink
Merge pull request #419 from MrCreosote/dev-gradle
Browse files Browse the repository at this point in the history
Switch from Ant -> Gradle
  • Loading branch information
MrCreosote authored Feb 14, 2024
2 parents 61dbc4d + 8fce168 commit 37bff04
Show file tree
Hide file tree
Showing 20 changed files with 653 additions and 663 deletions.
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ comment:
require_changes: no

ignore:
- "build"
- "deployment"
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

13 changes: 2 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ jobs:
auth2_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Note that there's a mongo-only ant test directive. Use that for all mongo versions
# except for one if there's > 1 mongo version to test. No need for testing code that
# doesn't touch mongo against multiple mongo versions
include:
- java: '8'
mongo: 'mongodb-linux-x86_64-ubuntu2204-7.0.4'
Expand All @@ -40,13 +38,6 @@ jobs:
distribution: 'temurin'
java-version: ${{matrix.java}}

- name: Clone jars as sister repo
shell: bash
run: |
cd ..
git clone https://github.com/kbase/jars
cd -
- name: Install mongo and set up test config
shell: bash
run: |
Expand All @@ -62,7 +53,7 @@ jobs:
cat test.cfg
- name: Run tests
run: ant test
run: ./gradlew test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
29 changes: 24 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
FROM kbase/sdkbase2 as build

COPY . /tmp/auth2
RUN cd /tmp \
&& git clone https://github.com/kbase/jars \
&& cd auth2 \
&& ant buildwar
WORKDIR /tmp/auth2

# dependencies take a while to D/L, so D/L & cache before the build so code changes don't cause
# a new D/L
# can't glob *gradle because of the .gradle dir
COPY build.gradle gradlew settings.gradle /tmp/auth2/
COPY gradle/ /tmp/auth2/gradle/
RUN ./gradlew dependencies

# Now build the code
COPY deployment/ /tmp/auth2/deployment/
COPY jettybase/ /tmp/auth2/jettybase/
COPY src /tmp/auth2/src/
COPY templates /tmp/auth2/templates/
COPY war /tmp/auth2/war/
# for the git commit
COPY .git /tmp/auth2/.git/
RUN ./gradlew war

FROM kbase/kb_jre:latest

Expand All @@ -15,6 +28,8 @@ ARG BRANCH=develop

COPY --from=build /tmp/auth2/deployment/ /kb/deployment/
COPY --from=build /tmp/auth2/jettybase/ /kb/deployment/jettybase/
COPY --from=build /tmp/auth2/build/libs/auth2.war /kb/deployment/jettybase/webapps/ROOT.war
COPY --from=build /tmp/auth2/templates /kb/deployment/jettybase/templates

# The BUILD_DATE value seem to bust the docker cache when the timestamp changes, move to
# the end
Expand All @@ -28,6 +43,10 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
WORKDIR /kb/deployment/jettybase
ENV KB_DEPLOYMENT_CONFIG=/kb/deployment/conf/deployment.cfg

# TODO BUILD update to no longer use dockerize and take env vars (e.g. like Collections).
# TODO BUILD figure out how to add multiple environments as env vars (multiline env vars in rancher?)
# TODO BUILD Use subsections in the ini file / switch to TOML

ENTRYPOINT [ "/kb/deployment/bin/dockerize" ]

# Here are some default params passed to dockerize. They would typically
Expand Down
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ Removes all test mode data from the system.
* Note that only the public API has been tested with the auth server.
* In version 0.6.0, the canonicalization algorithm for user display names changed and the
database needs to be updated.
* See the `--recanonicalize-display-names` option for the `manage_auth` script. This can
* See the `--recanonicalize-display-names` option for the `manage_auth` script
(See the administration section below). This can
be run while the server is live **after** updating to version 0.6.0.
* Once the names have been recanonicalized, the `--remove-recanonicalization-flag` can be
used to remove flags set on database objects to avoid reprocessing if the recanonicalize
Expand All @@ -235,29 +236,43 @@ Removes all test mode data from the system.
## Requirements

Java 8 (OpenJDK OK)
Apache Ant (http://ant.apache.org/)
MongoDB 2.6+ (https://www.mongodb.com/)
Jetty 9.3+ (http://www.eclipse.org/jetty/download.html)
(see jetty-config.md for version used for testing)
This repo (git clone https://github.com/kbase/auth2)
The jars repo (git clone https://github.com/kbase/jars)
The two repos above need to be in the same parent folder.

## To start server

Either use `docker-compose --build -d`, which is easier and starts the server in test mode
(which can be configured in the docker-compose file), or:

start mongodb
if using mongo auth, create a mongo user
cd into the auth2 repo
`ant build`
copy `deploy.cfg.example` to `deploy.cfg` and fill in appropriately
`export KB_DEPLOYMENT_CONFIG=<path to deploy.cfg>`
`cd jettybase`
`./jettybase$ java -jar -Djetty.port=<port> <path to jetty install>/start.jar`
cd into the auth2 repo

```
./gradlew war
mkdir -p jettybase/webapps
cp build/libs/auth2.war jettybase/webapps/ROOT.war
cp templates jettybase/templates
```

copy `deploy.cfg.example` to `deploy.cfg` and fill in appropriately

```
export KB_DEPLOYMENT_CONFIG=<path to deploy.cfg>
cd jettybase
./jettybase$ java -jar -Djetty.port=<port> <path to jetty install>/start.jar
```

## Administer the server

Create the administration script:

`./gradlew generateManageAuthScript`

Set a root password:
`./manage_auth -d <path to deploy.cfg> -r`
`build/manage_auth -d <path to deploy.cfg> -r`

Login to a local account as `***ROOT***` with the password you set. Create a
local account and assign it the create administrator role. That account can
Expand Down Expand Up @@ -293,7 +308,7 @@ Omit the stop key to have jetty generate one for you.

* Copy `test.cfg.example` to `test.cfg` and fill in the values appropriately.
* If it works as is start buying lottery tickets immediately.
* `ant test`
* `./gradlew test`

### UI

Expand Down
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Authentication Service MKII release notes

## 0.6.1

* Gradle has replaced Ant as the build tool. As a consequence, all the built artifacts
are now located in the `build` directory, including the `manage_auth` script.
* The MongoDB clients have been updated to the most recent version and the service tested
against Mongo 7.
* The docker-compose file has been updated to start an auth server in test mode.

## 0.6.0

* ADMIN ACTION REQUIRED - after the server is upgraded, use the `manage_auth` script to
Expand Down
Loading

0 comments on commit 37bff04

Please sign in to comment.