Merge pull request #974 from basecamp/proxy-boot-config
Proxy boot config
This commit is contained in:
@@ -19,6 +19,7 @@ RUN apt-get update --fix-missing && apt-get install -y docker-ce docker-ce-cli c
|
||||
COPY *.sh .
|
||||
COPY app/ app/
|
||||
COPY app_with_roles/ app_with_roles/
|
||||
COPY app_with_traefik/ app_with_traefik/
|
||||
|
||||
RUN rm -rf /root/.ssh
|
||||
RUN ln -s /shared/ssh /root/.ssh
|
||||
@@ -28,6 +29,7 @@ RUN git config --global user.email "deployer@example.com"
|
||||
RUN git config --global user.name "Deployer"
|
||||
RUN cd app && git init && git add . && git commit -am "Initial version"
|
||||
RUN cd app_with_roles && git init && git add . && git commit -am "Initial version"
|
||||
RUN cd app_with_traefik && git init && git add . && git commit -am "Initial version"
|
||||
|
||||
HEALTHCHECK --interval=1s CMD pgrep sleep
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
kamal proxy boot_config set --publish false \
|
||||
--docker_options label=traefik.http.services.kamal_proxy.loadbalancer.server.scheme=http \
|
||||
label=traefik.http.routers.kamal_proxy.rule=PathPrefix\(\`/\`\)
|
||||
@@ -0,0 +1 @@
|
||||
SECRET_TOKEN='1234 with "中文"'
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM registry:4443/nginx:1-alpine-slim
|
||||
|
||||
COPY default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
ARG COMMIT_SHA
|
||||
RUN echo $COMMIT_SHA > /usr/share/nginx/html/version
|
||||
RUN mkdir -p /usr/share/nginx/html/versions && echo "version" > /usr/share/nginx/html/versions/$COMMIT_SHA
|
||||
RUN mkdir -p /usr/share/nginx/html/versions && echo "hidden" > /usr/share/nginx/html/versions/.hidden
|
||||
RUN echo "Up!" > /usr/share/nginx/html/up
|
||||
@@ -0,0 +1,29 @@
|
||||
service: app_with_traefik
|
||||
image: app_with_traefik
|
||||
servers:
|
||||
- vm1
|
||||
- vm2
|
||||
deploy_timeout: 2
|
||||
drain_timeout: 2
|
||||
readiness_delay: 0
|
||||
|
||||
registry:
|
||||
server: registry:4443
|
||||
username: root
|
||||
password: root
|
||||
builder:
|
||||
driver: docker
|
||||
arch: <%= Kamal::Utils.docker_arch %>
|
||||
args:
|
||||
COMMIT_SHA: <%= `git rev-parse HEAD` %>
|
||||
accessories:
|
||||
traefik:
|
||||
service: traefik
|
||||
image: traefik:v2.10
|
||||
port: 80
|
||||
cmd: "--providers.docker"
|
||||
options:
|
||||
volume:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
roles:
|
||||
- web
|
||||
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
@@ -169,10 +169,8 @@ class IntegrationTest < ActiveSupport::TestCase
|
||||
case app
|
||||
when "app"
|
||||
"127.0.0.1"
|
||||
when "app_with_roles"
|
||||
"localhost"
|
||||
else
|
||||
raise "Unknown app: #{app}"
|
||||
"localhost"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,6 +88,14 @@ class MainTest < IntegrationTest
|
||||
end
|
||||
|
||||
test "setup and remove" do
|
||||
@app = "app_with_roles"
|
||||
|
||||
kamal :proxy, :set_config,
|
||||
"--publish=false",
|
||||
"--options=label=traefik.http.services.kamal_proxy.loadbalancer.server.scheme=http",
|
||||
"label=traefik.http.routers.kamal_proxy.rule=PathPrefix\\\(\\\`/\\\`\\\)",
|
||||
"label=traefik.http.routers.kamal_proxy.priority=2"
|
||||
|
||||
# Check remove completes when nothing has been setup yet
|
||||
kamal :remove, "-y"
|
||||
assert_no_images_or_containers
|
||||
@@ -123,6 +131,15 @@ class MainTest < IntegrationTest
|
||||
assert_proxy_not_running
|
||||
end
|
||||
|
||||
test "deploy with traefik" do
|
||||
@app = "app_with_traefik"
|
||||
|
||||
first_version = latest_app_version
|
||||
|
||||
kamal :setup
|
||||
assert_app_is_up version: first_version
|
||||
end
|
||||
|
||||
private
|
||||
def assert_envs(version:)
|
||||
assert_env :CLEAR_TOKEN, "4321", version: version, vm: :vm1
|
||||
|
||||
Reference in New Issue
Block a user