Skip to content

Commit

Permalink
docker-compose: use image tag from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosbarreto committed Jan 30, 2020
1 parent d3ebab6 commit e31b95e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SHELLHUB_VERSION=latest
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ services:
gateway:
build:
context: gateway
environment:
- SHELLHUB_VERSION=latest
agent:
build:
context: agent
Expand Down
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.7'

services:
ssh:
image: shellhubio/shellhub-ssh
image: shellhubio/shellhub-ssh:${SHELLHUB_VERSION}
environment:
- PRIVATE_KEY=/run/secrets/ssh_private_key
depends_on:
Expand Down Expand Up @@ -41,7 +41,7 @@ services:
protocol: tcp
mode: host
api:
image: shellhubio/shellhub-api
image: shellhubio/shellhub-api:${SHELLHUB_VERSION}
environment:
- PRIVATE_KEY=/run/secrets/api_private_key
- PUBLIC_KEY=/run/secrets/api_public_key
Expand All @@ -53,17 +53,19 @@ services:
- api_private_key
- api_public_key
ws:
image: shellhubio/shellhub-ws
image: shellhubio/shellhub-ws:${SHELLHUB_VERSION}
depends_on:
- ssh
links:
- ssh
ui:
image: shellhubio/shellhub-ui
image: shellhubio/shellhub-ui:${SHELLHUB_VERSION}
depends_on:
- api
gateway:
image: shellhubio/shellhub-gateway
image: shellhubio/shellhub-gateway:${SHELLHUB_VERSION}
environment:
- SHELLHUB_VERSION=${SHELLHUB_VERSION}
depends_on:
- api
- ws
Expand Down
1 change: 1 addition & 0 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FROM openresty/openresty:1.15.8.2-6-alpine

RUN ["rm", "/etc/nginx/conf.d/default.conf"]

COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
COPY shellhub.conf /etc/nginx/conf.d/
24 changes: 24 additions & 0 deletions gateway/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
worker_processes 1;

events {
worker_connections 1024;
}

env SHELLHUB_VERSION;

http {
include mime.types;
default_type application/octet-stream;

client_body_temp_path /var/run/openresty/nginx-client-body;
proxy_temp_path /var/run/openresty/nginx-proxy;
fastcgi_temp_path /var/run/openresty/nginx-fastcgi;
uwsgi_temp_path /var/run/openresty/nginx-uwsgi;
scgi_temp_path /var/run/openresty/nginx-scgi;

sendfile on;

keepalive_timeout 65;

include /etc/nginx/conf.d/*.conf;
}
3 changes: 2 additions & 1 deletion gateway/shellhub.conf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ server {
content_by_lua_block {
local host=ngx.var.http_host
local tenant_id=ngx.var.arg_tenant_id
ngx.say("docker run -d --restart=unless-stopped --privileged --net=host --pid=host -v /:/host -e SERVER_ADDRESS=http://",host," -e PRIVATE_KEY=/host/etc/shellhub.key -e TENANT_ID=",tenant_id," shellhubio/agent:latest")
local version=os.getenv("SHELLHUB_VERSION")
ngx.say("docker run -d --restart=unless-stopped --privileged --net=host --pid=host -v /:/host -e SERVER_ADDRESS=http://",host," -e PRIVATE_KEY=/host/etc/shellhub.key -e TENANT_ID=",tenant_id," shellhubio/agent:",version)
}
}
}

0 comments on commit e31b95e

Please sign in to comment.