Skip to content

Commit

Permalink
dim-web: add init Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
parsa97 authored and miesi committed Jul 26, 2024
1 parent 014ec4e commit 0e1451d
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 15 deletions.
34 changes: 34 additions & 0 deletions dim-web/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
32 changes: 32 additions & 0 deletions dim-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# syntax=docker/dockerfile:1
FROM debian:bullseye AS builder

RUN apt update \
&& apt install -y \
python2 \
npm

WORKDIR /dim-web

COPY package.json .
RUN npm install

COPY . .

ARG DIM_LOGIN
ARG DIM_RPC
ARG LOGIN
ARG LOGOUT
ARG BASE_URL

RUN build/replace-process-env-docker-build.sh && cat config/prod.env.js

RUN npm run build

# Run the final image
FROM nginx:1.21 AS final

# Copy the build files to the nginx server
COPY --from=builder /dim-web /var/www/html
COPY --from=builder /dim-web/dist/index.html /var/www/html/dist/static/
COPY config/dim-web.nginx.conf /etc/nginx/conf.d/
29 changes: 19 additions & 10 deletions dim-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
## Build Setup

You need to edit [prod.env.js](config/prod.env.js) or [dev.env.js](config/dev.env.js) depends on your need

Example:
```bash
DIM_LOGIN: '"https://dim.example.com/dim/login"',
DIM_RPC: '"https://dim.example.com/dim/jsonrpc"',
LOGIN: '"https://dim.example.com/cas"',
LOGOUT: '"https://dim.example.com/cas/logout"',
BASE_URL: '"/"',
```
Then start npm install and build
``` bash
# install dependencies
npm install
Expand All @@ -26,13 +37,11 @@ npm test

For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

## install cas handler

To install the cas handler, install the python module.

```
pip install ./
```

Copy `cas/config.py.example` to `config.py` or `/etc/dim/cas.cfg` and edit the
variables.
## Docker build
docker build --progress=plain \
--build-arg DIM_LOGIN=http://dim-nginx:8000/login \
--build-arg DIM_RPC=http://dim-nginx:8000/jsonrpc \
--build-arg LOGIN=http://dim-nginx:8000/dim-cas/ \
--build-arg LOGOUT=http://dim-nginx:8000/dim-cas/logout \
--build-arg BASE_URL=/web \
.
5 changes: 5 additions & 0 deletions dim-web/build/replace-process-env-docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sed -i "s@DIM_LOGIN_PLACE_HOLDER@$DIM_LOGIN@g" config/prod.env.js
sed -i "s@DIM_RPC_PLACE_HOLDER@$DIM_RPC@g" config/prod.env.js
sed -i "s@LOGIN_PLACE_HOLDER@$LOGIN@g" config/prod.env.js
sed -i "s@LOGOUT_PLACE_HOLDER@$LOGOUT@g" config/prod.env.js
sed -i "s@BASE_URL_PLACE_HOLDER@$BASE_URL@g" config/prod.env.js
14 changes: 14 additions & 0 deletions dim-web/config/dim-web.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
listen 8000;
server_name localhost;

location / {
root /var/www/html/dist/static;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
10 changes: 5 additions & 5 deletions dim-web/config/prod.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

module.exports = {
NODE_ENV: '"production"',
DIM_LOGIN: '"https://dim.example.com/dim/login"',
DIM_RPC: '"https://dim.example.com/dim/jsonrpc"',
LOGIN: '"https://dim.example.com/cas"',
LOGOUT: '"https://dim.example.com/cas/logout"',
BASE_URL: '"/"',
DIM_LOGIN:'"DIM_LOGIN_PLACE_HOLDER"',
DIM_RPC: '"DIM_RPC_PLACE_HOLDER"',
LOGIN: '"LOGIN_PLACE_HOLDER"',
LOGOUT: '"LOGOUT_PLACE_HOLDER"',
BASE_URL: '"BASE_URL_PLACE_HOLDER"',
SLEEP: 500
};

0 comments on commit 0e1451d

Please sign in to comment.