diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..2457f3044 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -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/buildkit-cache-dance@v3.1.0 + 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 diff --git a/.gitignore b/.gitignore index bfffbfa6c..e745623b6 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Dockerfile b/Dockerfile index 3b03f6931..ea6e2a0f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 @@ -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 diff --git a/app/femr/business/services/system/UserService.java b/app/femr/business/services/system/UserService.java index def5c8949..ad5558d5e 100644 --- a/app/femr/business/services/system/UserService.java +++ b/app/femr/business/services/system/UserService.java @@ -72,7 +72,11 @@ public ServiceResponse 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; } diff --git a/app/femr/data/models/core/IFeedback.java b/app/femr/data/models/core/IFeedback.java index bad20e752..0e7483dbf 100644 --- a/app/femr/data/models/core/IFeedback.java +++ b/app/femr/data/models/core/IFeedback.java @@ -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); } diff --git a/app/femr/data/models/mysql/Feedback.java b/app/femr/data/models/mysql/Feedback.java index b12e837ff..425f5c2da 100644 --- a/app/femr/data/models/mysql/Feedback.java +++ b/app/femr/data/models/mysql/Feedback.java @@ -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; @@ -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; +// } } diff --git a/app/femr/ui/controllers/FeedbackController.java b/app/femr/ui/controllers/FeedbackController.java index 04d204a91..8b926bb0f 100644 --- a/app/femr/ui/controllers/FeedbackController.java +++ b/app/femr/ui/controllers/FeedbackController.java @@ -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; @@ -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 @@ -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 @@ -57,11 +59,14 @@ public Result indexPost() { CurrentUser currentUser = sessionService.retrieveCurrentUserSession(); if(!viewModel.getFeedbackMsg().equals("")){ - userService.createFeedback(viewModel.getFeedbackMsg()); - return redirect("/"); + ServiceResponse 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)); } diff --git a/app/femr/ui/views/feedback/feedback.scala.html b/app/femr/ui/views/feedback/feedback.scala.html index afff4f964..cb7c8d867 100644 --- a/app/femr/ui/views/feedback/feedback.scala.html +++ b/app/femr/ui/views/feedback/feedback.scala.html @@ -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 @@ -53,7 +53,7 @@

Give Feedback

} - + @successMessage

Your feedback is completely anonymous and will only be used to produce a better fEMR product.

} diff --git a/conf/application.docker.conf b/conf/application.docker.conf index 408088703..b773210cf 100644 --- a/conf/application.docker.conf +++ b/conf/application.docker.conf @@ -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" diff --git a/docker-compose.yml b/docker-compose.yml index fb15e39d1..be16c8367 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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' diff --git a/public/css/feedback.css b/public/css/feedback.css index bbae2e2a6..2819f47f9 100644 --- a/public/css/feedback.css +++ b/public/css/feedback.css @@ -21,3 +21,6 @@ button#feedbackSubmit { margin: 10px 0; } +span{ + font-weight: bold; +} \ No newline at end of file