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

Use Docker multistate-build to containerize packaging #191

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ https://querydsl.com/*
https://uel.java.net/
https://www.openapis.org/
https://jcp.org/*
http://localhost:8080/*
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
# 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.
FROM maven:3.8.3-openjdk-17 as build

RUN mkdir /jersey-webservice-template
COPY . /jersey-webservice-template
RUN cd /jersey-webservice-template && mvn clean package -Dmaven.test.skip=true

FROM ubuntu:22.04

LABEL maintainer="Jiaqi (Jack) Liu"
Expand Down Expand Up @@ -41,7 +47,7 @@ RUN rm jetty-home-$JETTY_VERSION.tar.gz
RUN mkdir jetty-base
RUN cd jetty-base && java -jar $JETTY_HOME/start.jar --add-module=annotations,server,http,deploy,servlet,webapp,resources,jsp

COPY ./target/jersey-webservice-template-$WS_VERSION.war $JETTY_WEBAPPS_DIR/ROOT.war
COPY --from=build /jersey-webservice-template/target/jersey-webservice-template-$WS_VERSION.war $JETTY_WEBAPPS_DIR/ROOT.war

COPY ./Dockerfile-startup.sh /Dockerfile-startup.sh
CMD [ "/Dockerfile-startup.sh" ]
49 changes: 43 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,49 @@ Jersey Webservice Template
[![GitHub Workflow Status][GitHub Workflow Status]](https://github.com/QubitPi/jersey-webservice-template/actions/workflows/ci-cd.yml)
[![Apache License Badge]][Apache License, Version 2.0]

[Jersey Webservice Template (JWT)][jersey-webservice-template] is a [JSR 370] web service **template** that lets us
spin up Java web service quickly through [GitHub templates]. At the end of the day, JWT helps organization to **improve
the velocity and quality of their teams' work**
__Jersey Webservice Template__ (__JWT__) is a [JSR 370] webservice template that lets us spin up Java webservice quickly
through [GitHub templates]. One can think of JWT as the Jersey/Jetty version of [Spring Initializr]. At the end of the
day, JWT helps organization to improve the velocity and quality of their teams' work

Documentation
-------------
Quick Start
-----------

Comprehensive documentation is viewable on our [website][Documentation]
Please make sure Docker is installed
([_Installing Docker_](https://docker.qubitpi.org/desktop/setup/install/mac-install/)), then execute this on-click
commands:

```console
docker run --name=jersey-webservice-template -it -p 8080:8080 jack20191124/jersey-webservice-template
```

That's it. A healthcheck endpoint can be pinned with

```console
curl -v localhost:8080/v1/data/healthcheck
```

which would gave

```console
$ curl -v localhost:8080/v1/data/healthcheck
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /v1/data/healthcheck HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Length: 0
< Server: Jetty(11.0.15)
<
* Connection #0 to host localhost left intact
```

Developer can now start adding business values without repeating the time-consuming scaffolding works. To proceed from
here, including getting and developing the webservice source code, please refer to the [documentation][Documentation]
for details.

License
-------
Expand All @@ -30,3 +65,5 @@ The use and distribution terms for [jersey-webservice-template] are covered by t
[Java Version Badge]: https://img.shields.io/badge/Java-17-brightgreen?style=for-the-badge&logo=OpenJDK&logoColor=white
[jersey-webservice-template]: https://qubitpi.github.io/jersey-webservice-template/
[JSR 370]: https://jcp.org/en/jsr/detail?id=370

[Spring Initializr]: https://start.spring.io/
46 changes: 2 additions & 44 deletions docs/docs/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

JAX-RS Jersey doesn't specify how application configurations are to be loaded. jersey-webservice-template, however,
utilizes a library called [owner](https://owner.qubitpi.org/).
utilizes a library called [owner].

The configurations in this page can be set from several sources in the following order:

Expand All @@ -21,49 +21,7 @@ The configurations in this page can be set from several sources in the following
Note that environment config has higher priority than Java system properties. Java system properties have higher
priority than file based configuration.

[owner]: https://owner.qubitpi.org/

CI/CD
-----

The following [GitHub Action Secrets][GitHub Action - How to set up] needs to be setup:

| **Secret Name** | **Definition** | **How to Get** |
|-----------------------|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| DOCKERHUB_USERNAME | You Docker Hub username | For example, [this user][Docker - an user example]'s is `jack20191124` |
| DOCKERHUB_TOKEN | A personal access token (PAT) to use as an Docker CLI authentication from within GitHub Action | [Creating an access token][Docker - Creating an access token] |
| AWS_WS_PKRVARS_HCL | The [HashiCorp Packer variable values file] contents | [hashicorp-aws][hashicorp-aws webservice] |
| SSL_CERTIFICATE | SSL cert file for exposing webservice API via secure HTTPS | [Installing Free SSL Certificates with Certbot running on Nginx] |
| SSL_CERTIFICATE_KEY | SSL cert key file for exposing webservice API via secure HTTPS | [Installing Free SSL Certificates with Certbot running on Nginx] |
| NGINX_CONFIG_FILE | Config file for Nginx as a HTTPS reverse proxy | [Define Nginx Reverse Proxy Config File] |
| FILEBEAT_CONFIG_FILE | The standard filebeat.yml file contents | [Configure Filebeat] |
| AWS_WS_TFVARS | The [HashiCorp Terraform variable values file] contents | [hashicorp-aws][hashicorp-aws webservice] |
| MAVEN_SETTINGS_XML | The contents of [Maven settings file] for the Webservice project | The exact settings.xml contents containing [these meta tags][JWT JPA Maven setting tags] |
| OAUTH_PROPERTIES | The contents of the `src/main/resources/oauth.properties` mentioned above | See [Security](#oauth-2) section above |
| AWS_ACCESS_KEY_ID | The exact same AWS_ACCESS_KEY_ID as mentioned in [Environment variables to configure the AWS CLI] | [How to create and configure AWS credentials for Amazon Keyspaces] |
| AWS_SECRET_ACCESS_KEY | The exact same AWS_SECRET_ACCESS_KEY as mentioned in [Environment variables to configure the AWS CLI] | [How to create and configure AWS credentials for Amazon Keyspaces] |
| AWS_REGION | The exact same AWS_REGION as mentioned in [Environment variables to configure the AWS CLI] | [How to create and configure AWS credentials for Amazon Keyspaces] |

[GitHub Action - How to set up]: https://docs.github.com/en/actions/security-guides/encrypted-secrets

[Configure Filebeat]: https://www.elastic.co/guide/en/beats/filebeat/current/configuring-howto-filebeat.html

[Define Nginx Reverse Proxy Config File]: https://hashistack.org/docs/setup#step-3---define-nginx-reverse-proxy-config-file
[Docker - Creating an access token]: https://docs.docker.com/security/for-developers/access-tokens/#create-an-access-token
[Docker - an user example]: https://hub.docker.com/u/jack20191124

[Environment variables to configure the AWS CLI]: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

[hashicorp-aws webservice]: https://hashistack.org/docs/webservice
[HashiCorp Packer variable values file]: https://qubitpi.github.io/hashicorp-packer/packer/guides/hcl/variables#from-a-file
[HashiCorp Terraform variable values file]: https://qubitpi.github.io/hashicorp-terraform/terraform/language/values/variables#variable-definitions-tfvars-files
[How to create and configure AWS credentials for Amazon Keyspaces]: https://docs.aws.amazon.com/keyspaces/latest/devguide/access.credentials.html

[Installing Free SSL Certificates with Certbot running on Nginx]: https://hashistack.org/docs/setup#step-1---store-ssl-certificate-in-github-secrets

[Java system properties]: https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
[JWT JPA Maven setting tags]: https://github.com/QubitPi/jersey-webservice-template/blob/jpa-elide/settings.xml.example

[Maven settings file]: https://maven.apache.org/settings.html

[operating system's environment variables]: https://docs.oracle.com/javase/tutorial/essential/environment/env.html
[owner]: https://owner.qubitpi.org/
Loading
Loading