Skip to content

Commit

Permalink
fix: frontend config with new assetbundle aproach dropwizard4
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Dec 5, 2023
1 parent 122e6d2 commit 60f4c28
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 38 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ RUN mvn verify --fail-never -U

COPY backend/ ./

# Copy frontend build to local resources classpath folder
ENV FRONTEND_PATH=/app/src/main/resources/frontend
COPY --from=frontend-build ./frontend/build $FRONTEND_PATH

RUN mvn -Dmaven.test.skip=true package

FROM wirebot/runtime:1.4.0 AS runtime
Expand All @@ -28,9 +32,6 @@ RUN apt-get update && apt-get upgrade -y
# Copy backend
COPY --from=build /app/target/roman.jar /opt/roman/backend/
COPY backend/roman.yaml /etc/roman/
# Copy frontend
ENV FRONTEND_PATH=/opt/roman/frontend
COPY --from=frontend-build ./frontend/build $FRONTEND_PATH

# create version file
ARG release_version=development
Expand Down
5 changes: 0 additions & 5 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-servlets</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard-bundles</groupId>
<artifactId>dropwizard-configurable-assets-bundle</artifactId>
<version>1.3.5</version>
</dependency>
<!-- MIGRATION TO JAKARTA JETTY 11 -->
<dependency>
<groupId>jakarta.annotation</groupId>
Expand Down
7 changes: 0 additions & 7 deletions backend/roman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ swagger:
- https
- http

assets:
mappings:
/assets: /
overrides:
# the default assumes you have build frontend by "npm run build"
/: ${FRONTEND_PATH:-../frontend/build}

jerseyClient:
timeout: 40s
connectionTimeout: 40s
Expand Down
15 changes: 4 additions & 11 deletions backend/src/main/java/com/wire/bots/roman/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,15 @@
package com.wire.bots.roman;

import com.wire.bots.roman.commands.UpdateCertCommand;
import com.wire.bots.roman.filters.BackendAuthenticationFilter;
import com.wire.bots.roman.filters.CspResponseFilter;
import com.wire.bots.roman.filters.ProxyAuthenticationFilter;
import com.wire.bots.roman.filters.ServiceAuthenticationFilter;
import com.wire.bots.roman.filters.ServiceTokenAuthenticationFilter;
import com.wire.bots.roman.filters.*;
import com.wire.bots.roman.model.Config;
import com.wire.bots.roman.resources.BroadcastResource;
import com.wire.bots.roman.resources.ConversationResource;
import com.wire.bots.roman.resources.MessagesResource;
import com.wire.bots.roman.resources.ProviderResource;
import com.wire.bots.roman.resources.ServiceResource;
import com.wire.bots.roman.resources.UsersResource;
import com.wire.bots.roman.resources.*;
import com.wire.lithium.ClientRepo;
import com.wire.lithium.Server;
import com.wire.xenon.MessageHandlerBase;
import com.wire.xenon.factories.CryptoFactory;
import com.wire.xenon.factories.StorageFactory;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import io.jsonwebtoken.security.Keys;
Expand Down Expand Up @@ -70,6 +62,7 @@ public void initialize(Bootstrap<Config> bootstrap) {
instance = (Application) bootstrap.getApplication();
bootstrap.addBundle(new WebsocketBundle(WebSocket.class));
bootstrap.addCommand(new UpdateCertCommand());
bootstrap.addBundle(new AssetsBundle("/frontend", "/", "index.html"));
}

@Override
Expand Down
13 changes: 1 addition & 12 deletions backend/src/main/java/com/wire/bots/roman/model/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.wire.lithium.Configuration;
import io.dropwizard.bundles.assets.AssetsBundleConfiguration;
import io.dropwizard.bundles.assets.AssetsConfiguration;
import io.dropwizard.validation.ValidationMethod;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

public class Config extends Configuration implements AssetsBundleConfiguration {
public class Config extends Configuration {
@NotNull
@JsonProperty
public String key;
Expand All @@ -45,14 +42,6 @@ public class Config extends Configuration implements AssetsBundleConfiguration {
@JsonProperty
public String romanPubKeyBase64;

@JsonProperty
public AssetsConfiguration assets;

@Override
public AssetsConfiguration getAssetsConfiguration() {
return assets;
}

@ValidationMethod(message = "`romanPubKeyBase64` is not in a valid base64 format")
@JsonIgnore
public boolean pubKeyFormatIsNotValid() {
Expand Down

0 comments on commit 60f4c28

Please sign in to comment.