Skip to content

Commit

Permalink
meta
Browse files Browse the repository at this point in the history
  • Loading branch information
akdasa committed Apr 30, 2023
1 parent f62630d commit 89a28f8
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions .container/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -f http://localhost/balancer/_meta
1 change: 1 addition & 0 deletions .container/meta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION=dev
1 change: 1 addition & 0 deletions run.sh → .container/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if [[ -z "${BALANCER_ENV}" ]]; then
fi

echo "Starting nginx for ${BALANCER_ENV}"
cd /app/shlokas-balancer

# render template
envsubst "\$BALANCER_ENV" < ./config/nginx.conf.template > ./config/nginx.conf
Expand Down
13 changes: 11 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@
"shutdownAction": "stopCompose",
"overrideCommand": true,
"onCreateCommand": ".devcontainer/on_create.sh",
"workspaceFolder": "/app/shlokas-balancer"
}
"workspaceFolder": "/app/shlokas-balancer",
"customizations": {
"vscode": {
"extensions": [
"william-voyek.vscode-nginx",
"jakebathman.nginx-log-highlighter",
"raynigon.nginx-formatter"
]
}
}
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.logs
.DS_Store
.meta
config/nginx.conf
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"label": "Run",
"type": "shell",
"command": "./run.sh",
"command": ".container/run.sh",
"icon": {
"id": "server",
},
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG BALANCER_VERSION=dev
# Copy the nginx configuration files
WORKDIR /app/shlokas-balancer
COPY . .
RUN echo "VERSION=${BALANCER_VERSION}" > .meta
RUN echo "VERSION=${BALANCER_VERSION}" > .container/meta

# Run nginx
CMD ["/app/shlokas-balancer/run.sh"]
CMD ["/app/shlokas-balancer/.container/run.sh"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ Nginx Load Balancer for Shlokas. This is a simple load balancer for the Shlokas

## Development

`run.sh` will start the server in development mode. This will start the server in port `80` and will redirect requests to the backend servers.
`.container/run.sh` will start the server in development mode. This will start the server in port `80` and will redirect requests to the backend servers.

### Endable HTTPS for local development

1. Add `127.0.0.1 shlokas.dev` to `/etc/hosts`:
2. Add `rootCA.rem` as trusted root certificate.
3. Copy `certs/server.csr` and `certs/server.key` to `.secrets/balancer/certs`
4. Run `BALANCER_ENV=prod run.sh`
4. Run `BALANCER_ENV=prod .container/run.sh`


## Production

1. Copy `server.csr` and `server.key` to `.secrets/balancer/certs`
2. `BALANCER_ENV=prod run.sh` will start the server in production mode.
2. `BALANCER_ENV=prod .container/run.sh` will start the server in production mode.

8 changes: 4 additions & 4 deletions config/endpoints.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
location /balancer/_meta {
default_type application/json;
access_log off;
error_log off;
alias /app/shlokas-balancer/.meta;
default_type text/plain;
access_log off;
error_log off;
alias /app/shlokas-balancer/.container/meta;
}

location / {
Expand Down

0 comments on commit 89a28f8

Please sign in to comment.