Skip to content

Commit 1eb36ba

Browse files
committed
2 parents b50f23d + b480b05 commit 1eb36ba

53 files changed

Lines changed: 966 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dockerfile

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
FROM golang:1.9.6 AS build
1+
FROM golang:1.11.0-alpine AS build
22
ADD . /src
33
WORKDIR /src
4-
RUN go get -d -v -t
5-
RUN go test --cover ./... --run UnitTest
6-
RUN go build -v -o docker-flow-proxy
4+
RUN set -x \
5+
&& apk add --update --no-cache --no-progress git g++ \
6+
&& go get -d -v \
7+
&& go test --cover ./... --run UnitTest \
8+
&& go build -v -o docker-flow-proxy
79

810

9-
FROM haproxy:1.8.8-alpine
10-
MAINTAINER Viktor Farcic <viktor@farcic.com>
11+
FROM haproxy:1.8.13-alpine
12+
LABEL org.opencontainers.image.title="Docker Flow Proxy" \
13+
org.opencontainers.image.description="Automated HAProxy Reverse Proxy for Docker" \
14+
org.opencontainers.image.url="https://proxy.dockerflow.com" \
15+
org.opencontainers.image.licenses="MIT" \
16+
org.opencontainers.image.authors="Viktor Farcic <viktor@farcic.com>" \
17+
org.opencontainers.image.source="https://github.com/docker-flow/docker-flow-proxy"
1118

12-
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
13-
RUN mkdir -p /cfg/tmpl /templates /certs /logs
19+
RUN apk --update --no-cache --no-progress add tini \
20+
&& mkdir -p /cfg/tmpl /templates /certs /logs
1421

1522
ENV CERTS="" \
1623
CAPTURE_REQUEST_HEADER="" \
@@ -39,21 +46,20 @@ ENV CERTS="" \
3946
TIMEOUT_HTTP_REQUEST="5" TIMEOUT_HTTP_KEEP_ALIVE="15" TIMEOUT_CLIENT="20" TIMEOUT_CONNECT="5" TIMEOUT_QUEUE="30" TIMEOUT_SERVER="20" TIMEOUT_TUNNEL="3600" \
4047
USERS="" \
4148
SKIP_ADDRESS_VALIDATION="true" \
42-
SSL_BIND_OPTIONS="no-sslv3" SSL_BIND_CIPHERS="ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS"
49+
SSL_BIND_OPTIONS="no-sslv3" \
50+
SSL_BIND_CIPHERS="ECDH+AESGCM:ECDH+CHACHA20:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS"
4351

44-
EXPOSE 80
45-
EXPOSE 443
46-
EXPOSE 8080
52+
EXPOSE 80 \
53+
443 \
54+
8080
4755

48-
RUN apk --no-cache add tini
4956
ENTRYPOINT ["/sbin/tini", "-g", "--"]
5057
CMD ["docker-flow-proxy", "server"]
5158
HEALTHCHECK --interval=5s --start-period=3s --timeout=10s CMD check.sh
5259

5360
COPY scripts/check.sh /usr/local/bin/check.sh
54-
RUN chmod +x /usr/local/bin/check.sh
5561
COPY errorfiles /errorfiles
5662
COPY haproxy.cfg /cfg/haproxy.cfg
5763
COPY haproxy.tmpl /cfg/tmpl/haproxy.tmpl
5864
COPY --from=build /src/docker-flow-proxy /usr/local/bin/docker-flow-proxy
59-
RUN chmod +x /usr/local/bin/docker-flow-proxy
65+
RUN chmod +x /usr/local/bin/docker-flow-proxy /usr/local/bin/check.sh

Dockerfile.packetbeat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apk add --update \
77
bash \
88
ca-certificates \
99
&& update-ca-certificates
10-
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
10+
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
1111
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
1212
RUN apk add glibc-2.25-r0.apk
1313

Dockerfile.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM dockerflow/docker-flow-proxy-test-base
1+
FROM thomasjpfan/docker-flow-proxy-test-base
22

33
COPY . /src
44
WORKDIR /src
55
RUN chmod +x /src/run-tests.sh
6-
RUN go get -d -v -t
6+
RUN go get -d -v
77

88
CMD ["sh", "-c", "/src/run-tests.sh"]

Dockerfile.test-base

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
FROM golang:1.8
1+
FROM golang:1.11.0-alpine3.8
22

3-
MAINTAINER Viktor Farcic <viktor@farcic.com>
4-
5-
RUN apt-get update && \
6-
apt-get install -y apt-transport-https ca-certificates curl software-properties-common expect && \
7-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
8-
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
9-
apt-get update && \
10-
apt-get -y install docker-ce
3+
RUN apk add --no-cache --update git docker gcc libc-dev

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pipeline {
1515
def dateFormat = new SimpleDateFormat("yy.MM.dd")
1616
currentBuild.displayName = dateFormat.format(new Date()) + "-" + env.BUILD_NUMBER
1717
}
18-
dfBuild2("docker-flow-proxy")
18+
dfBuild2("docker-flow-proxy", "thomasjpfan/gox-build:0.1.1-1.11.0-alpine3.8")
1919
sh "docker image build -t dockerflow/docker-flow-proxy:latest-packet-beat -f Dockerfile.packetbeat ."
2020
sh "docker image tag dockerflow/docker-flow-proxy:latest-packet-beat dockerflow/docker-flow-proxy:${currentBuild.displayName}-packet-beat"
2121
}
@@ -53,7 +53,7 @@ pipeline {
5353
label "prod"
5454
}
5555
steps {
56-
dfDeploy2("docker-flow-proxy", "proxy_proxy", "proxy_docs")
56+
sh "helm upgrade -i docker-flow-proxy helm/docker-flow-proxy --namespace df --set image.tag=${currentBuild.displayName}"
5757
}
5858
}
5959
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Docker Flow Proxy
22

3+
**This project needs adoption. I (@vfarcic) moved to Kubernetes and cannot dedicate time to this project anymore. Similarly, involvement from other contributors dropped as well. Please consider contributing yourself if you think this project is useful.**
4+
35
[![GitHub release](https://img.shields.io/github/release/docker-flow/docker-flow-proxy.svg)]()
46
[![license](https://img.shields.io/github/license/docker-flow/docker-flow-proxy.svg)]()
57
[![Docker Pulls](https://img.shields.io/docker/pulls/vfarcic/docker-flow-proxy.svg)]()

actions/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"net/http"
77
"strings"
88

9-
"../proxy"
9+
"github.com/docker-flow/docker-flow-proxy/proxy"
1010
)
1111

1212
// Fetchable defines interface that fetches information from other sources

actions/fetch_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package actions
22

33
import (
4-
"../proxy"
54
"encoding/json"
65
"fmt"
7-
"github.com/stretchr/testify/suite"
86
"net/http"
97
"net/http/httptest"
108
"os"
119
"strings"
1210
"testing"
11+
12+
"github.com/docker-flow/docker-flow-proxy/proxy"
13+
"github.com/stretchr/testify/suite"
1314
)
1415

1516
type FetchTestSuite struct {
@@ -25,12 +26,12 @@ type FetchTestSuite struct {
2526
func (s *FetchTestSuite) SetupTest() {
2627
sd := proxy.ServiceDest{
2728
ServicePath: []string{"path/to/my/service/api", "path/to/my/other/service/api"},
29+
PathType: "path_beg",
2830
}
2931
s.InstanceName = "proxy-test-instance"
3032
s.ServiceDest = []proxy.ServiceDest{sd}
3133
s.ConfigsPath = "path/to/configs/dir"
3234
s.TemplatesPath = "test_configs/tmpl"
33-
s.PathType = "path_beg"
3435
s.fetch = fetch{
3536
BaseReconfigure: BaseReconfigure{
3637
TemplatesPath: s.TemplatesPath,

actions/reconfigure.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strconv"
99
"strings"
1010

11-
"../proxy"
11+
"github.com/docker-flow/docker-flow-proxy/proxy"
1212
)
1313

1414
const serviceTemplateFeFilename = "service-formatted-fe.ctmpl"
@@ -59,6 +59,17 @@ func (m *Reconfigure) Execute(reloadAfter bool) error {
5959
return err
6060
}
6161
}
62+
// Not global and replicas == 0, the service is not active
63+
if !m.Service.IsGlobal && m.Service.Replicas == 0 {
64+
action := NewRemove(
65+
m.Service.ServiceName,
66+
m.Service.AclName,
67+
m.ConfigsPath,
68+
m.TemplatesPath,
69+
m.InstanceName,
70+
)
71+
return action.Execute([]string{})
72+
}
6273
if err := m.createConfigsAddService(); err != nil {
6374
return err
6475
}

actions/reconfigure_test.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"testing"
77

8-
"../proxy"
8+
"github.com/docker-flow/docker-flow-proxy/proxy"
99
"github.com/stretchr/testify/mock"
1010
"github.com/stretchr/testify/suite"
1111
)
@@ -24,12 +24,12 @@ func (s *ReconfigureTestSuite) SetupTest() {
2424
sd := proxy.ServiceDest{
2525
ServicePath: []string{"path/to/my/service/api", "path/to/my/other/service/api"},
2626
Index: 0,
27+
PathType: "path_beg",
2728
}
2829
s.InstanceName = "proxy-test-instance"
2930
s.ServiceDest = []proxy.ServiceDest{sd}
3031
s.ConfigsPath = "path/to/configs/dir"
3132
s.TemplatesPath = "test_configs/tmpl"
32-
s.PathType = "path_beg"
3333
s.reconfigure = Reconfigure{
3434
BaseReconfigure: BaseReconfigure{
3535
TemplatesPath: s.TemplatesPath,
@@ -40,7 +40,7 @@ func (s *ReconfigureTestSuite) SetupTest() {
4040
ServiceName: s.ServiceName,
4141
AclName: s.ServiceName,
4242
ServiceDest: []proxy.ServiceDest{sd},
43-
PathType: s.PathType,
43+
Replicas: 1,
4444
},
4545
}
4646
os.Setenv("SKIP_ADDRESS_VALIDATION", "true")
@@ -122,6 +122,7 @@ func (s ReconfigureTestSuite) Test_GetTemplates_UsesServerTemplate_WhenDiscovery
122122
s.reconfigure.Service.ServiceDest[0].Port = "1234"
123123
s.reconfigure.Service.DiscoveryType = "DNS"
124124
s.reconfigure.Service.Replicas = 0
125+
s.reconfigure.Service.IsGlobal = true
125126
expected := `
126127
backend myService-be1234_0
127128
mode http
@@ -428,6 +429,7 @@ backend https-myService-be4321_0
428429
s.reconfigure.ServiceDest[0].Port = "1234"
429430
s.reconfigure.ServiceDest[0].HttpsPort = 4321
430431
s.reconfigure.Replicas = 0
432+
s.reconfigure.IsGlobal = true
431433
s.reconfigure.DiscoveryType = "DNS"
432434
actualFront, actualBack, _ := s.reconfigure.GetTemplates()
433435

@@ -739,7 +741,8 @@ func (s ReconfigureTestSuite) Test_Execute_WritesServerSession() {
739741
s.reconfigure.AclName = "my-service"
740742
s.reconfigure.ServiceDest[0].Port = "1111"
741743
s.reconfigure.ServiceDest[0].HttpsPort = 2222
742-
s.reconfigure.Tasks = []string{"1.2.3.4", "4.3.2.1"}
744+
// The expectedData will place these ips in order
745+
s.reconfigure.Tasks = []string{"4.3.2.1", "1.2.3.4"}
743746
s.reconfigure.SessionType = "sticky-server"
744747
var actualData string
745748
expectedData := `
@@ -1033,6 +1036,19 @@ func (s ReconfigureTestSuite) Test_Execute_RemovesService_WhenProxyFails() {
10331036
mockObj.AssertCalled(s.T(), "RemoveService", s.ServiceName)
10341037
}
10351038

1039+
func (s ReconfigureTestSuite) Test_Execute_RemovesService_WhenReplicasIs0() {
1040+
s.reconfigure.Service.Replicas = 0
1041+
1042+
mockObj := getProxyMock("")
1043+
proxyOrig := proxy.Instance
1044+
defer func() { proxy.Instance = proxyOrig }()
1045+
proxy.Instance = mockObj
1046+
1047+
s.reconfigure.Execute(true)
1048+
1049+
mockObj.AssertCalled(s.T(), "RemoveService", s.ServiceName)
1050+
}
1051+
10361052
func (s ReconfigureTestSuite) Test_Execute_ReloadsAgain_WhenProxyFails() {
10371053
mockObj := getProxyMock("Reload")
10381054
mockObj.On("Reload").Return(fmt.Errorf("This is an error"))
@@ -1052,11 +1068,12 @@ func (s ReconfigureTestSuite) Test_Execute_AddsService() {
10521068
proxy.Instance = mockObj
10531069
sd := proxy.ServiceDest{
10541070
ServicePath: []string{"path/to/my/service/api", "path/to/my/other/service/api"},
1071+
PathType: "path_beg",
10551072
}
10561073
expected := proxy.Service{
10571074
ServiceName: "s.ServiceName",
10581075
ServiceDest: []proxy.ServiceDest{sd},
1059-
PathType: s.PathType,
1076+
Replicas: 1,
10601077
}
10611078
r := NewReconfigure(
10621079
BaseReconfigure{
@@ -1135,12 +1152,13 @@ func (s *ReconfigureTestSuite) Test_Execute_WhenFilterProxyInstanceIsTrue_SamePr
11351152
proxy.Instance = mockObj
11361153
sd := proxy.ServiceDest{
11371154
ServicePath: []string{"path/to/my/service/api", "path/to/my/other/service/api"},
1155+
PathType: "path_beg",
11381156
}
11391157
expected := proxy.Service{
11401158
ServiceName: s.ServiceName,
11411159
ServiceDest: []proxy.ServiceDest{sd},
1142-
PathType: s.PathType,
11431160
ProxyInstanceName: s.InstanceName,
1161+
Replicas: 1,
11441162
}
11451163
r := NewReconfigure(
11461164
BaseReconfigure{
@@ -1167,11 +1185,11 @@ func (s *ReconfigureTestSuite) Test_Execute_WhenFilterProxyInstanceIsTrue_Differ
11671185
proxy.Instance = mockObj
11681186
sd := proxy.ServiceDest{
11691187
ServicePath: []string{"path/to/my/service/api", "path/to/my/other/service/api"},
1188+
PathType: "path_beg",
11701189
}
11711190
expected := proxy.Service{
11721191
ServiceName: s.ServiceName,
11731192
ServiceDest: []proxy.ServiceDest{sd},
1174-
PathType: s.PathType,
11751193
ProxyInstanceName: "another-docker-flow",
11761194
}
11771195
r := NewReconfigure(

0 commit comments

Comments
 (0)