generated from bcgov/quickstart-openshift
-
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.
Fix: readme, guides and docker compose files (#91)
* docs: add docker compose files for backend and database * docs: add reame and contributing files, docker compose and maven config * feat: add optional port from env var for oracle-api docker healtcheck * fix: wrong oracle driver class name causing warnings * docs: update oracle-api readme to include docker running instructions * feat: update oracle-api to use proper healthcheck from actuator * docs: add docker compose files for backend and database * docs: add reame and contributing files, docker compose and maven config * feat: update to use only one docker-compose file * feat: removed unused files and fixed readme * chore: remove unused docker compose file * fix: remove clipboard feature from react-serve in frontend * fix: upgrade eclipse-temruin for oracle-api dockerfile * Swap curl for wget * fix: add pyhton3 to Dockerfile so it builds on machines with Apple chips * fix: update allowed cors origins rule in oracle and postgres server * fix: remove access control allow origin rule in frontend * fix: attempt to make backend wait for db to be ready to accept connection --------- Co-authored-by: Craig Yu <craig.yu93@gmail.com> Co-authored-by: Derek Roberts <derek.roberts@gmail.com>
- Loading branch information
1 parent
9677a78
commit 5dcb3aa
Showing
22 changed files
with
768 additions
and
916 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 |
---|---|---|
|
@@ -102,3 +102,6 @@ snyk.sarif | |
|
||
# VS Code | ||
.vscode | ||
|
||
# Artifacts | ||
*.jar |
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
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,18 @@ | ||
# 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. | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
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,144 @@ | ||
# Contributing guide | ||
|
||
Thanks for taking a moment and reading this guide. Is very important to have | ||
everyone on the same page. This guide describes how to: | ||
- Set up your environment | ||
- Run this application | ||
- Run tests | ||
- Submit pull requests | ||
- Follow our code practices | ||
|
||
(If you are new to GitHub, you might start with a [basic tutorial](https://help.github.com/articles/set-up-git) and check out a more detailed guide to [pull requests](https://help.github.com/articles/using-pull-requests/).) | ||
|
||
All contributors retain the original copyright to their stuff, but by | ||
contributing to this project, you grant a world-wide, royalty-free, | ||
perpetual, irrevocable, non-exclusive, transferable license to all | ||
users **under the terms of the [license](./LICENSE.md) under which | ||
this project is distributed**. | ||
|
||
## Set up your environment | ||
|
||
### Git | ||
|
||
Make sure you have Git installed on your machine. You can follow | ||
[this link](https://git-scm.com/downloads) for instructions. | ||
|
||
### Docker | ||
|
||
We containerize our application with Docker images. | ||
|
||
Note: things are way | ||
easier if you don't need to run docker commands with root (sudo). Take a look | ||
[here](https://docs.docker.com/engine/install/#server) to learn how to | ||
install. Note that Docker Desktop shouldn't be used for this project, | ||
due to license matters. | ||
|
||
### Java and Maven | ||
|
||
An easy way of getting both Java and Maven on your machine is using | ||
SDK Man. Take a look [here](https://sdkman.io/) to learn how to install. | ||
For this project we're using Java 17 (OpenSDK). | ||
|
||
### IDE | ||
|
||
We recommend IntelliJ IDEA Community, because all of its plugins and | ||
configurations possibilities, here's [the website](https://www.jetbrains.com/idea/download). | ||
But feel free to use Eclipse or other IDE of your choice. | ||
|
||
### Code style | ||
|
||
Our Java code is formatted following the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). | ||
A formatter and plugins based on it for Eclipse and IntelliJ are available and make writing | ||
style-conformant code quite easy. Check the installation notes on the | ||
[formatter's project page](https://github.com/google/google-java-format). | ||
|
||
We configured a tool to validate changes submitted to us in accordance to our style guide. **Passing | ||
such validation, however, doesn't mean that the code conforms to the style guide**, as some rules | ||
cannot be checked by this tool. We ask you to check if your code adheres to the following rules | ||
before submitting it. | ||
|
||
- [2.2 File encoding: UTF-8](https://google.github.io/styleguide/javaguide.html#s2.2-file-encoding) | ||
- [5.2.2 Class names](https://google.github.io/styleguide/javaguide.html#s5.2.2-class-names) | ||
- [5.2.3 Method names](https://google.github.io/styleguide/javaguide.html#s5.2.3-method-names) | ||
- [5.2.4 Constant names](https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names) | ||
- [5.3 Camel case: defined](https://google.github.io/styleguide/javaguide.html#s5.3-camel-case) | ||
- [6.1 @Override: always used](https://google.github.io/styleguide/javaguide.html#s6.1-override-annotation) | ||
|
||
You can check your code before submitting with `./mvnw --no-transfer-progress checkstyle:checkstyle -Dcheckstyle.skip=false --file pom.xml` | ||
|
||
## Run this application | ||
|
||
After setting up your environment you might want to see this service running. | ||
You can get it up and running by typing (in the project root directory): | ||
|
||
```sh | ||
./mvnw spring-boot:run | ||
``` | ||
|
||
In case you want to debug with remote JVM, you can do it with this command: | ||
|
||
```sh | ||
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" | ||
``` | ||
|
||
Note: You need a running Postgres service to have a fully working environment. You | ||
can do that with Docker or Docker and the Compose plugin. Follow these steps: | ||
|
||
```sh | ||
cd database | ||
docker-compose up --build | ||
``` | ||
|
||
## Run tests | ||
|
||
For unit tests, please use this command: | ||
|
||
```sh | ||
./mvnw test --file pom.xml | ||
``` | ||
|
||
And for integration tests: | ||
|
||
```sh | ||
./mvnw verify -P integration-test --file pom.xml | ||
``` | ||
|
||
Tests coverage and reports can be seen on your commits and pull requests. | ||
But in case you want to check it locally, use this command to run all tests: | ||
|
||
```sh | ||
./mvnw --no-transfer-progress clean verify -P all-tests --file pom.xml | ||
``` | ||
|
||
And check out the html file generated: | ||
|
||
```sh | ||
x-www-browser target/coverage-reports/merged-test-report/index.html # For Linux | ||
open target/coverage-reports/merged-test-report/index.html # For MacOS | ||
``` | ||
|
||
## Submit pull requests | ||
|
||
We use git flow, so all code changes happen through Pull Requests. There's a | ||
Pull Request template that you can fill. The more complete the better. If you | ||
have images, screen capture or diagrams, that helps a lot. Don't forget to add | ||
reviewers, assign to yourself and add a label. | ||
|
||
## Database versioning | ||
|
||
Any permanent alteration to the database schema (creation or alteration of tables, | ||
columns, etc.) should be done through Flyway. [Here's a brief explanation on how | ||
versioning with Flyway works](https://flywaydb.org/documentation/getstarted/how). | ||
|
||
Each migration should have its own file, which must follow [this naming | ||
pattern](https://flywaydb.org/documentation/concepts/migrations#naming). | ||
|
||
## Follow our best practices | ||
|
||
- Java source code must be formatted according to | ||
[Google Java Style Guide](https://google.github.io/styleguide/javaguide.html), | ||
as mentioned. There's a pipeline to unsure all of our code is good to go. | ||
- We try to use [conventional commits](https://www.conventionalcommits.org/) | ||
because it makes the process of generating changelogs way easier. So we encourage | ||
you to read at least the [summary](https://www.conventionalcommits.org/en/v1.0.0/#summary) | ||
that summarize and give some examples. |
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
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,101 @@ | ||
# SPAR Back-end REST API | ||
|
||
This repository holds a set of policies, standards, guides, and pipelines to | ||
get started with a back-end API. Before writing your first line of code, please | ||
take a moment and check out our [CONTRIBUTING](CONTRIBUTING.md) guide. | ||
|
||
## Our Policy | ||
|
||
- Work in the open: That means that everything we do should be open, should be | ||
public. Please, don't create private repositories unless you have a very strong | ||
reason. Keeping things public is a must follow rule for BC Government. | ||
- Customer centred services: All the work that's been created is to improve users, | ||
customers, and friends usability and experience. Is important to keep that in mind | ||
because as engineers sometimes we face technical issues, however, our goal is | ||
to have a good product. | ||
- Community based work: Remember that you're not alone. It's very likely that | ||
your problem is someone else's problem. Let's figure it out together. So, ask | ||
a question using our channels. We have [our own Stackoverflow](https://stackoverflow.developer.gov.bc.ca/) | ||
and [our Rocket Chat](https://chat.developer.gov.bc.ca/) channel. | ||
|
||
# Stack | ||
|
||
Here you can find a comprehensive list of all languages and tools that are been used | ||
in this service. And also everything you need to get started, build locally, test | ||
and deploy it. | ||
|
||
- Java ecosystem | ||
- Maven | ||
- Open JDK 17 | ||
- Spring Web MVC Framework | ||
- JPA and Hibernate Framework | ||
- Testing | ||
- JUnit 5 | ||
- Mockito and Mock MVC | ||
- Automated tests with Postman and Newman | ||
- Database | ||
- PostgreSQL | ||
- Versioning with [Flyway](https://flywaydb.org/) | ||
- DevOps | ||
- Docker | ||
- Docker Composer | ||
- Sonar Cloud | ||
- Deploy to OpenShift with GitHub Actions | ||
- Tools (Recommendations) | ||
- IntelliJ IDEA | ||
- Postman | ||
- DBeaver | ||
|
||
# Getting started | ||
|
||
Once you have cloned this repository, can get it running by typing: `./mvnw spring-boot:run` | ||
from the project root directory. You **must** provide three environment variables for database | ||
access configuration: | ||
|
||
Then head to http://localhost:8090/actuator/health to check if the system was successfully launched: | ||
the `status` property should have the value *UP*. | ||
|
||
Before writing your first line of code, and learn more about the checks, including | ||
tests, please take a moment and check out our [CONTRIBUTING](CONTRIBUTING.md) guide. | ||
|
||
## Quick look | ||
|
||
If all you want is to take a quick look at the running service, you can do it by using Docker Compose. | ||
|
||
Be aware of the required environment variables: | ||
|
||
```sh | ||
FORESTCLIENTAPI_KEY=[key-here] | ||
|
||
``` | ||
|
||
✅ You can export all environment variables from a .env file with this command (On Linux): | ||
|
||
```sh | ||
export $(cat .env | xargs) | ||
``` | ||
|
||
Run with (from the project root): | ||
```sh | ||
docker-compose up --build backend -d | ||
``` | ||
|
||
⚠️ You'll need a PostgreSQL database running. Here's how you can get it up and running: | ||
|
||
Run with (from the project root): | ||
```sh | ||
docker-compose up --build database -d | ||
``` | ||
|
||
Use this environment variables | ||
|
||
```sh | ||
POSTGRES_USER=postgres | ||
POSTGRES_DB=postgres | ||
POSTGRES_PASSWORD=default | ||
``` | ||
|
||
## Getting help | ||
|
||
As mentioned, we're here to help. Feel free to start a conversation | ||
on Rocket chat or ask a question on Stackoverflow. |
Oops, something went wrong.