Skip to content

Commit

Permalink
simplify docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
falcowinkler committed Jul 4, 2024
1 parent c3c8adf commit 7635ae6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
11 changes: 0 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
FROM quay.io/keycloak/keycloak:latest as builder

ENV KC_HEALTH_ENABLED=true

WORKDIR /opt/keycloak

# for demonstration purposes only
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/
ADD start.sh /start.sh

ENV PORT=${PORT:-8080}
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ Right now, auth.js keycloak is a simple docker deployment on ec2.

### Prerequisites

- External database
- SSL certificates (generated with certbot/letsencrypt, for example)

Then, the docker container is started like this:

```bash
export KEYCLOAK_DB_URL=<JDBC-URL>
export KEYCLOAK_ADMIN_PASSWORD=<Password>
export KEYCLOAK_HOSTNAME=keycloak.authjs.dev
export KEYCLOAK_DB_USERNAME=<DB-Username>
export KEYCLOAK_DB_PASSWORD=<DB-password>

docker run -d --name authjs-keycloak -v /path-to-letsencrypt-certificates:/certificates -p 443:443 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=$KEYCLOAK_ADMIN_PASSWORD quay.io/keycloak/keycloak:latest start --features=token-exchange --https-certificate-file=/certificates/fullchain.pem --https-certificate-key-file=/certificates/privkey.pem --hostname=$KEYCLOAK_HOSTNAME --proxy=edge --https-port=443 --db=postgres --db-url=$KEYCLOAK_DB_URL --db-username=$KEYCLOAK_DB_USERNAME --db-password=$KEYCLOAK_DB_PASSWORD
docker run -d --name authjs-keycloak -v /path-to-letsencrypt-certificates:/certificates -p 443:443 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=$KEYCLOAK_ADMIN_PASSWORD quay.io/keycloak/keycloak:latest start --features=token-exchange --https-certificate-file=/certificates/fullchain.pem --https-certificate-key-file=/certificates/privkey.pem --hostname=$KEYCLOAK_HOSTNAME --proxy=edge --https-port=443
```
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
ARGS="$@"
/opt/keycloak/bin/kc.sh start --optimized $ARGS &
/opt/keycloak/bin/kc.sh $ARGS &

KEYCLOAK_PID=$!

Expand Down

0 comments on commit 7635ae6

Please sign in to comment.