-
Notifications
You must be signed in to change notification settings - Fork 80
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
feat: added docker-compose environment for quick deployments #2320
Open
Vorstenbosch
wants to merge
2
commits into
hmislk:master
Choose a base branch
from
Vorstenbosch:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/target/ | ||
/src/main/webapp/WEB-INF/glassfish-resources.xml | ||
/faces-config.NavData | ||
.data |
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,26 @@ | ||
FROM maven:3.9.6-eclipse-temurin-11 as builder | ||
|
||
COPY . /tmp | ||
|
||
RUN cd /tmp && mvn package | ||
|
||
FROM alpine:3.19.0 as dependencies | ||
|
||
ENV MYSQL_DRIVER_VERSION=mysql-connector-j-8.2.0 | ||
|
||
RUN apk update && apk add curl unzip | ||
WORKDIR /tmp/mysql | ||
RUN curl --location --output "${MYSQL_DRIVER_VERSION}.zip" "https://dev.mysql.com/get/Downloads/Connector-J/${MYSQL_DRIVER_VERSION}.zip" | ||
RUN unzip "${MYSQL_DRIVER_VERSION}.zip" && cp ${MYSQL_DRIVER_VERSION}/*.jar . | ||
|
||
FROM payara/server-full:5.2020.3-jdk11 | ||
|
||
ENV GLASSFISH_HOME=/opt/payara/appserver | ||
ENV PREBOOT_COMMANDS=/opt/custom/create-datasource.asadmin | ||
|
||
COPY deployment/create-datasource.asadmin "${PREBOOT_COMMANDS}" | ||
COPY --from=dependencies /tmp/mysql/*.jar "${GLASSFISH_HOME}/glassfish/lib/" | ||
COPY --from=builder /tmp/target/*.war "${GLASSFISH_HOME}/../deployments/hmis.war" | ||
|
||
EXPOSE 8080/tcp | ||
EXPOSE 4848/tcp |
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,27 @@ | ||
# Sample deployment using containers | ||
This folder is a sample on how to quickly spin-up (or deploy) the HMIS app together with a database. By following this guide you do not have to run java, a database or a webserver locally on your computer. Everything comes out of the box and can be cleaned up quickly. | ||
|
||
## Requirements | ||
- docker | ||
- internet connection | ||
- open ports: 3306, 4848, 8080 | ||
|
||
## How to use | ||
All commands in subchapters assume you are in the `deployment` directory. | ||
|
||
### Starting the environment | ||
``` | ||
docker compose up --build | ||
``` | ||
|
||
After some time the app will be automatically deployed to the server, including the creation of connection pool and JDBC resource. You can find the app at `localhost:8080/horizon`. | ||
|
||
### Stopping the environment | ||
``` | ||
docker compose down | ||
``` | ||
To remove the entire database (to start fresh) add ` --volumes; rm -r .data` to the end of the stop command. | ||
|
||
### Other tips | ||
- It is still possible to interact with the admin console of the payara (glassfish) webserver at `localhost:4848`. The username for the root user is `admin` and the password is `admin`. | ||
- You can open a mysql client connection by 'stepping into' the mysql container by running `docker exec -it deployment_db_1 bash` and once you are inside the mysql container run `mysql -ppassword` ('password' is the password here). You can also use any other sql tool and connect to localhost:3306. |
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,3 @@ | ||
create-jdbc-connection-pool --datasourceclassname=com.mysql.cj.jdbc.MysqlDataSource --restype=javax.sql.ConnectionPoolDataSource --property user=hmis:password=hmis:serverName=db:portNumber=3306:databaseName=hmis:useSSL=false dbPool | ||
create-jdbc-resource --connectionpoolid dbPool jdbc/arogya | ||
create-jdbc-resource --connectionpoolid dbPool jdbc/arogyaAudit |
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,25 @@ | ||
services: | ||
hmis: | ||
build: | ||
context: ../ | ||
dockerfile: deployment/Dockerfile | ||
depends_on: | ||
- db | ||
ports: | ||
- "4848:4848" | ||
- "8080:8080" | ||
environment: {} | ||
db: | ||
image: "mysql:8.2.0" | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: hmis | ||
MYSQL_USER: hmis | ||
MYSQL_PASSWORD: hmis | ||
volumes: | ||
- .data:/var/lib/mysql | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
data: |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking on this