add Docker and docker-compose (#456)

* add Docker and docker-compose

* dockerize - build and expose through nginx

* update README.md for docker usage
This commit is contained in:
Nicola Beghin 2021-03-23 11:07:46 +01:00 committed by GitHub
parent bf4cae6735
commit 6c4aa0b100
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 1 deletions

4
.dockerignore Normal file
View file

@ -0,0 +1,4 @@
.git
cypress
.github
.storybook

34
Dockerfile Normal file
View file

@ -0,0 +1,34 @@
ARG DEFAULT_KEYCLOAK_ENDPOINT='http:\/\/localhost:8180'
FROM node:12 as builder
ARG DEFAULT_KEYCLOAK_ENDPOINT
ARG KEYCLOAK_ENDPOINT
# install updated yarn
RUN rm -fr /usr/local/bin/yarn* &&\
npm install -g yarn
WORKDIR /app
COPY . .
# replace Keycloak endpoints
RUN sed -i "s/${DEFAULT_KEYCLOAK_ENDPOINT}/${KEYCLOAK_ENDPOINT}/g" import.js &&\
sed -i "s/${DEFAULT_KEYCLOAK_ENDPOINT}/${KEYCLOAK_ENDPOINT}/g" src/context/auth/keycloak.ts &&\
sed -i "s/adminv2//g" snowpack.config.js &&\
yarn &&\
yarn build
FROM nginx:stable
ARG DEFAULT_KEYCLOAK_ENDPOINT
ARG KEYCLOAK_ENDPOINT
COPY --from=builder /app/build /usr/share/nginx/html
# setup reverse proxy for Keycloak endpoint
COPY nginx-default.conf /etc/nginx/conf.d/default.conf
# replace Keycloak endpoints
RUN sed -i "s/${DEFAULT_KEYCLOAK_ENDPOINT}/${KEYCLOAK_ENDPOINT}/g" /etc/nginx/conf.d/default.conf
EXPOSE 80

View file

@ -27,6 +27,18 @@ For development on this project you will need a running Keycloak server listenin
$> yarn start
```
### Build and run through Docker
git checkout git@github.com:keycloak/keycloak-admin-ui.git
cd keycloak-admin-ui
docker-compose build
docker-compose up
You can reach the new admin interface at http://localhost
If your Keycloak instance is not on `localhost:8180`, create a file `.env` with the following:
KEYCLOAK_ENDPOINT=https:\/\/remoteinstance.keycloak.com
### Additionally there are some nice scripts to format and lint
```bash

9
docker-compose.yml Normal file
View file

@ -0,0 +1,9 @@
version: '3'
services:
keycloak-admin-ui:
build:
context: .
args:
KEYCLOAK_ENDPOINT: ${KEYCLOAK_ENDPOINT:-'http:\/\/localhost:8180'}
ports:
- "80:80"

39
nginx-default.conf Normal file
View file

@ -0,0 +1,39 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
location /auth/ {
client_max_body_size 0;
proxy_pass http://localhost:8180/auth/;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

View file

@ -9,7 +9,8 @@
"clientAuthenticatorType": "client-secret",
"redirectUris": [
"/adminv2/*",
"http://localhost:8080/*"
"http://localhost:8080/*",
"http://localhost/*"
],
"webOrigins": [
"*"