-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Initial attempt at using `caddy` * chore: Add caddy support to devcontainer * chore: Fix refs to Node container in `Makefile` * feat: Use relative API paths and take host from env * chore: Need `caddy` in the devcontainer * feat: Serve up app via Caddy and proxy the API * feat: Add `/auth-config` endpoint to `Caddyfile` * feat: Add util function for retrieving auth config * feat: Fetch auth config during app setup and `provide` it * feat: Use auth config in `useAuth` composable * test: `useAuth` without auth config provided * feat: Add custom entrypoint to ensure we have the required environment variables * chore: Use the Docker layer cache when building * chore: Ensure we're actually using our Dockerfile (whoops) * chore: Need a `CMD` * chore: No need to persist `/config` * chore: Make `eslint` ignore build directories * feat: Support local dev via Vue and Caddy * feat: Allow for auth config in Vue dev * feat: Add `reload-caddy-dev` `Makefile` command for convenience
- Loading branch information
Showing
21 changed files
with
388 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
FROM public.ecr.aws/docker/library/node:20.12-slim | ||
FROM public.ecr.aws/docker/library/node:20.12-slim as builder | ||
|
||
WORKDIR /usr/cron-mon/app | ||
|
||
RUN npm install -g npm@latest | ||
|
||
COPY ./app . | ||
ENV PATH /usr/cron-mon/app/node_modules/.bin:$PATH | ||
|
||
RUN npm install && npm run build | ||
|
||
FROM public.ecr.aws/docker/library/caddy:2.9 | ||
|
||
COPY ./entrypoint.sh /entrypoint.sh | ||
COPY --from=builder /usr/cron-mon/app/dist /srv | ||
COPY ./app/Caddyfile /etc/caddy/Caddyfile | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
install: build-containers npm-install | ||
install: build-containers | ||
|
||
build-containers: | ||
docker compose build --no-cache | ||
docker compose build | ||
|
||
npm-install: | ||
docker compose run --rm app bash -c 'npm install' | ||
docker compose run --rm dev bash -c 'npm install' | ||
|
||
build-app: | ||
docker compose run --rm --no-deps app bash -c 'npm run build' | ||
docker compose run --rm --no-deps dev bash -c 'npm run build' | ||
|
||
run: | ||
docker compose up app | ||
docker compose up caddy | ||
|
||
run-caddy-dev: | ||
docker compose up caddy-dev | ||
|
||
run-vue-dev: | ||
docker compose up vue-dev | ||
|
||
reload-caddy-dev: | ||
docker compose exec caddy-dev caddy reload --config /etc/caddy/Caddyfile | ||
|
||
test: static-test unit-test | ||
|
||
unit-test: | ||
docker compose run --rm --no-deps app bash -c 'npm run test:unit' | ||
docker compose run --rm --no-deps vue-dev bash -c 'npm run test:unit' | ||
|
||
static-test: | ||
docker compose run --rm --no-deps app bash -c 'npm run lint && npm run type-check' | ||
docker compose run --rm --no-deps vue-dev bash -c 'npm run lint && npm run type-check' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_API_HOST= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
VITE_API_HOST=$API_HOST | ||
VITE_KEYCLOAK_URL=$KEYCLOAK_URL | ||
VITE_KEYCLOAK_REALM=$KEYCLOAK_REALM | ||
VITE_KEYCLOAK_CLIENT_ID=$KEYCLOAK_CLIENT_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
VITE_KEYCLOAK_URL=http://keycloak | ||
VITE_KEYCLOAK_REALM=keycloak-realm | ||
VITE_KEYCLOAK_CLIENT_ID=keycloak-client-id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ module.exports = { | |
"ignoreRestSiblings": true | ||
} | ||
] | ||
} | ||
}, | ||
ignorePatterns: ["dist", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
:3000 { | ||
# Access logs | ||
log { | ||
format filter { | ||
# No need for any headers to be in any of the logs | ||
# (might be useful to be able to switch these on though?) | ||
request>headers delete | ||
resp_headers delete | ||
|
||
wrap json { | ||
message_key message | ||
time_key time | ||
time_format rfc3339 | ||
} | ||
} | ||
} | ||
|
||
encode gzip zstd | ||
|
||
# Provide dynamic Keycloak config. | ||
handle /auth-config { | ||
header { | ||
Content-Type application/json | ||
} | ||
respond 200 { | ||
# Caddy docs say we can use heredocs here, but it doesn't work, and the caddy formatter | ||
# doesn't like the newlines in the string, so we have to do it like this. | ||
body ` { | ||
"url": "{$KEYCLOAK_URL}", | ||
"realm": "{$KEYCLOAK_REALM}", | ||
"client": "{$KEYCLOAK_CLIENT_ID}" | ||
} | ||
` | ||
} | ||
} | ||
|
||
# Proxy the Cron Mon API. | ||
handle /api/* { | ||
reverse_proxy {$API_HOST} | ||
} | ||
|
||
# Serve up the frontend application. | ||
handle { | ||
root * /srv | ||
try_files {path}.html {path} /index.html | ||
file_server | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.