Skip to content

Commit

Permalink
Merge pull request #320 from softwareconstruction240/fix-loki-host-bug
Browse files Browse the repository at this point in the history
Fix loki host bug
  • Loading branch information
pawlh authored Apr 14, 2024
2 parents 880205c + 195dbd2 commit c1883d6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 45 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
49 changes: 48 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
networks:
autograder:

services:
db:
image: mysql:latest
Expand All @@ -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",
Expand All @@ -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 <<EOF > /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:
Expand Down
43 changes: 0 additions & 43 deletions loki-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
<http>
<url>http://localhost:3100/loki/api/v1/push</url>
<url>http://${LOKI_URL}/loki/api/v1/push</url>
</http>
<format>
<label>
Expand Down

0 comments on commit c1883d6

Please sign in to comment.