diff --git a/Dockerfile b/Dockerfile index 26c942536..58417e561 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,8 @@ RUN apt-get update && \ COPY --from=builder /app/target/automatico-1.0-SNAPSHOT.jar /app/target/ +ENV LOKI_URL="loki:3100" + EXPOSE 8080 CMD ["java", "-Dlog4j2.configurationFile=log4j.properties", "-Dlog4j2.debug=false", "-jar", "/app/target/automatico-1.0-SNAPSHOT.jar"] diff --git a/README.md b/README.md index 6f6a0cf6c..be2721d8e 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,14 @@ To generate a Canvas API key: 6. Copy the generated access token 7. Use it as the value of the `--canvas-token` program argument above +#### Environment Variables +If you are running Loki locally (not required), then you must set the following environment variable: +``` +LOKI_URL= +``` + +The value can be either `localhost:3100` (if you are NOT using docker to develop the app) or `loki:3100` (if you are using docker to develop the app). + #### Running Locally The frontend can be easily deployed by navigating to the correct directory, and calling an init script. diff --git a/compose.yml b/compose.yml index 95630547b..fb6f43cb9 100644 --- a/compose.yml +++ b/compose.yml @@ -1,3 +1,6 @@ +networks: + autograder: + services: db: image: mysql:latest @@ -10,8 +13,11 @@ services: - db-data:/var/lib/mysql ports: - "3306:3306" + networks: + - autograder + app: - image: pawlh/cs240-autograder:latest + image: ghcr.io/softwareconstruction240/autograder:latest ports: - "8080:8080" command: ["java", "-Dlog4j2.configurationFile=log4j.properties", "-Dlog4j2.debug=false", "-jar", "/app/target/automatico-1.0-SNAPSHOT.jar", @@ -25,6 +31,47 @@ services: "--canvas-token", "changeme", "--use-canvas", "true", ] + networks: + - autograder + + loki: + image: grafana/loki:2.9.0 + ports: + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml + networks: + - autograder + + grafana: + environment: + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + entrypoint: + - sh + - -euc + - | + mkdir -p /etc/grafana/provisioning/datasources + cat < /etc/grafana/provisioning/datasources/ds.yaml + apiVersion: 1 + datasources: + - name: Loki + type: loki + access: proxy + orgId: 1 + url: http://loki:3100 + basicAuth: false + isDefault: true + version: 1 + editable: false + EOF + /run.sh + image: grafana/grafana:latest + ports: + - "3000:3000" + networks: + - autograder + watchtower: container_name: watchtower volumes: diff --git a/loki-compose.yml b/loki-compose.yml deleted file mode 100644 index 51c12e648..000000000 --- a/loki-compose.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: "3" - -networks: - loki: - -services: - loki: - image: grafana/loki:2.9.0 - ports: - - "3100:3100" - command: -config.file=/etc/loki/local-config.yaml - networks: - - loki - - grafana: - environment: - - GF_PATHS_PROVISIONING=/etc/grafana/provisioning - - GF_AUTH_ANONYMOUS_ENABLED=true - - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - entrypoint: - - sh - - -euc - - | - mkdir -p /etc/grafana/provisioning/datasources - cat < /etc/grafana/provisioning/datasources/ds.yaml - apiVersion: 1 - datasources: - - name: Loki - type: loki - access: proxy - orgId: 1 - url: http://loki:3100 - basicAuth: false - isDefault: true - version: 1 - editable: false - EOF - /run.sh - image: grafana/grafana:latest - ports: - - "3000:3000" - networks: - - loki \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 9258e562b..34062dfe6 100755 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -30,7 +30,7 @@ - http://localhost:3100/loki/api/v1/push + http://${LOKI_URL}/loki/api/v1/push