Skip to content

Commit

Permalink
Merge branch 'master' into brendan
Browse files Browse the repository at this point in the history
# Conflicts:
#	Dockerfile
  • Loading branch information
bholt13 committed Dec 7, 2024
2 parents 2182a54 + 51cc4cc commit ace72f5
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 40 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker Image CI/CD

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
push_to_registry:
name: Push Docker Image to Docker Hub
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_EMAIL }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker Dependencies
uses: actions/cache@v3
with:
path: |
root/.ivy2
root/.sbt
key: sbt-${{ runner.os }}-${{ hashFiles('**/build.sbt', '**/project/*.sbt') }}
restore-keys: |
sbt-${{ runner.os }}-
- name: Inject sbt cache into Docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"root/.ivy2": "/root/.ivy2",
"root/.sbt": "/root/.sbt"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build and Push Docker Image to Registry
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name != 'pull_request' }}
tags: teamfemrdev/teamfemr:latest
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ hs_err_pid*
# except for .gitignore
!.gitignore

#except for .github/workflows
!.github

conf/application.conf
conf/application.*.conf
conf/application.example.conf
Expand Down
36 changes: 18 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM sbtscala/scala-sbt:eclipse-temurin-jammy-8u352-b08_1.9.0_2.12.17 AS builder

#build varaibles
#ENV SBT_VERSION 1.1.5
ENV PROJECT_HOME /usr/src
ENV PROJECT_HOME=/usr/src

#RUN mkdir -p $PROJECT_HOME/activator $PROJECT_HOME/app

Expand All @@ -22,28 +22,28 @@ RUN apt-get update && apt-get install -y \

# Install curl
#RUN \
# apt-get update && \
# apt-get -y install curl
# apt-get update && \
# apt-get -y install curl

# Install sbt
#RUN \
#mkdir /working/ && \
#cd /working/ && \
#curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \
#dpkg -i sbt-$SBT_VERSION.deb && \
#rm sbt-$SBT_VERSION.deb && \
#apt-get update && \
#apt-get install sbt && \
#cd && \
#rm -r /working/ && \
#sbt sbtVersion
#mkdir /working/ && \
#cd /working/ && \
#curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \
#dpkg -i sbt-$SBT_VERSION.deb && \
#rm sbt-$SBT_VERSION.deb && \
#apt-get update && \
#apt-get install sbt && \
#cd && \
#rm -r /working/ && \
#sbt sbtVersion

COPY Build.sbt .
COPY project ./project

RUN --mount=type=cache,target=/root/.ivy2 \
--mount=type=cache,target=/root/.sbt \
sbt update
--mount=type=cache,target=/root/.sbt \
sbt update

# Setup path variables and copy fEMR into container
#ENV PATH $PROJECT_HOME/activator/activator-dist-1.3.10/bin:$PATH
Expand All @@ -70,9 +70,9 @@ RUN apk add --no-cache bash python3 py3-pip gcc python3-dev musl-dev linux-heade
RUN pip3 install psutil

#database variables
ENV DB_URL "jdbc:mysql://localhost:3306/femr_db?characterEncoding=UTF-8&useSSL=false"
ENV DB_USER "username"
ENV DB_PASS "password"
ENV DB_URL="jdbc:mysql://localhost:3306/femr_db?characterEncoding=UTF-8&useSSL=false"
ENV DB_USER="username"
ENV DB_PASS="password"

COPY --from=builder /usr/src/app/target/universal/femr-* /opt/bin/femr

Expand Down
6 changes: 5 additions & 1 deletion app/femr/business/services/system/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public ServiceResponse<Boolean> createFeedback(String feedback) {
newFeedback.setDate(dateUtils.getCurrentDateTime());
newFeedback.setFeedback(feedback);

feedbackRepository.create(newFeedback);
if (feedbackRepository.create(newFeedback) != null){
response.setResponseObject(true);
}else{
response.setResponseObject(false);
}

return response;
}
Expand Down
4 changes: 2 additions & 2 deletions app/femr/data/models/core/IFeedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IFeedback {
void setDate (DateTime theDate);
void setFeedback (String theFeedback);

String getLanguageCode();
void setLanguageCode(String languageCode);
// String getLanguageCode();
// void setLanguageCode(String languageCode);

}
22 changes: 11 additions & 11 deletions app/femr/data/models/mysql/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Feedback implements IFeedback {
@Column(name = "feedback", nullable = false)
private String feedback;

@Column(name="language_code", nullable=true, length=5)
private String languageCode;
// @Column(name="language_code", nullable=true, length=5)
// private String languageCode;



Expand Down Expand Up @@ -55,14 +55,14 @@ public void setFeedback (String theFeedback) {
feedback = theFeedback;
}

@Override
public String getLanguageCode() {
return this.languageCode;
}

@Override
public void setLanguageCode(String languageCode) {
this.languageCode = languageCode;
}
// @Override
// public String getLanguageCode() {
// return this.languageCode;
// }
//
// @Override
// public void setLanguageCode(String languageCode) {
// this.languageCode = languageCode;
// }

}
15 changes: 10 additions & 5 deletions app/femr/ui/controllers/FeedbackController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import femr.business.services.core.ISessionService;
import femr.business.services.core.IUserService;
import femr.common.dtos.CurrentUser;
import femr.common.dtos.ServiceResponse;
import femr.data.models.mysql.Roles;
import femr.ui.helpers.security.AllowedRoles;
import femr.ui.helpers.security.FEMRAuthenticated;
Expand All @@ -28,6 +29,7 @@ public class FeedbackController extends Controller {
private final ISessionService sessionService;
private final FormFactory formFactory;
private final IUserService userService;
private String SuccessMessage = "";


@Inject
Expand All @@ -47,7 +49,7 @@ public FeedbackController( AssetsFinder assetsFinder,
// GET
public Result indexGet() {
CurrentUser currentUser = sessionService.retrieveCurrentUserSession();
return ok(feedback.render(currentUser, assetsFinder));
return ok(feedback.render(currentUser, assetsFinder, SuccessMessage));
}

// POST
Expand All @@ -57,11 +59,14 @@ public Result indexPost() {
CurrentUser currentUser = sessionService.retrieveCurrentUserSession();

if(!viewModel.getFeedbackMsg().equals("")){
userService.createFeedback(viewModel.getFeedbackMsg());
return redirect("/");
ServiceResponse<Boolean> success = userService.createFeedback(viewModel.getFeedbackMsg());
if (success.getResponseObject()){
SuccessMessage = "Successfully sent feedback!";
return ok(feedback.render(currentUser, assetsFinder, SuccessMessage));
}
}

return redirect("/feedback");
SuccessMessage = "Failed to send feedback. Please try again or contact a nerd!";
return ok(feedback.render(currentUser, assetsFinder, SuccessMessage));
}


Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/feedback/feedback.scala.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@(currentUser: femr.common.dtos.CurrentUser, assets: AssetsFinder)
@(currentUser: femr.common.dtos.CurrentUser, assets: AssetsFinder, successMessage: java.lang.String)

@import femr.ui.views.html.layouts.main
@import femr.ui.controllers.routes.FeedbackController
Expand Down Expand Up @@ -53,7 +53,7 @@ <h2 id="feedback_header">Give Feedback</h2>
<textarea class="fTextArea" name="feedbackMsg" id="usrFeedback" cols="50" rows="10" maxlength="10000" required></textarea>
<button type="submit" class="fButton fSubmitButton" id="feedback_submit">Submit</button>
}

<span id="feedback_success_message">@successMessage</span>
<p id="feedback_disclaimer">Your feedback is completely anonymous and will only be used to produce a better fEMR product.</p>
</div>
}
1 change: 1 addition & 0 deletions conf/application.docker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ csv.path="./Upload/CSV"

#Register eBean classes
ebean.default=["femr.data.models.*"]
play.evolutions.db.default.autoApply=true

#Register Guice modules
play.modules.enabled += "femr.util.dependencyinjection.modules.BusinessLayerModule"
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ services:
- "--log-bin-trust-function-creators=1"
volumes:
- db-data:/var/lib/mysql
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10

femr:
build: .
links:
- db:mysql
depends_on:
- db
db:
condition: service_healthy
tty: true
restart: on-failure:10
ports:
- '9000:9000'

Expand Down
3 changes: 3 additions & 0 deletions public/css/feedback.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ button#feedbackSubmit {
margin: 10px 0;
}

span{
font-weight: bold;
}

0 comments on commit ace72f5

Please sign in to comment.