@@ -7,8 +7,6 @@ SHA := $(shell git rev-parse HEAD)
7
7
VERSION_GIT := $(if $(TAG_NAME ) ,$(TAG_NAME ) ,$(SHA ) )
8
8
VERSION := $(if $(VERSION ) ,$(VERSION ) ,$(VERSION_GIT ) )
9
9
10
- BIND_DIR := dist
11
-
12
10
GIT_BRANCH := $(subst heads/,,$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) )
13
11
TRAEFIK_DEV_IMAGE := traefik-dev$(if $(GIT_BRANCH ) ,:$(subst /,-,$(GIT_BRANCH ) ) )
14
12
@@ -29,22 +27,22 @@ TRAEFIK_ENVS := \
29
27
-e CI \
30
28
-e CONTAINER=DOCKER # Indicator for integration tests that we are running inside a container.
31
29
32
- TRAEFIK_MOUNT := -v "$(CURDIR ) /$( BIND_DIR ) :/go/src/github.com/traefik/traefik/$( BIND_DIR ) "
30
+ TRAEFIK_MOUNT := -v "$(CURDIR ) /dist :/go/src/github.com/traefik/traefik/dist "
33
31
DOCKER_RUN_OPTS := $(TRAEFIK_ENVS ) $(TRAEFIK_MOUNT ) "$(TRAEFIK_DEV_IMAGE ) "
34
32
DOCKER_NON_INTERACTIVE ?= false
35
33
DOCKER_RUN_TRAEFIK := docker run $(INTEGRATION_OPTS ) $(if $(DOCKER_NON_INTERACTIVE ) , , -it) $(DOCKER_RUN_OPTS )
36
34
DOCKER_RUN_TRAEFIK_TEST := docker run --add-host=host.docker.internal:127.0.0.1 --rm --name=traefik --network traefik-test-network -v $(PWD ) :$(PWD ) -w $(PWD ) $(INTEGRATION_OPTS ) $(if $(DOCKER_NON_INTERACTIVE ) , , -it) $(DOCKER_RUN_OPTS )
37
35
DOCKER_RUN_TRAEFIK_NOTTY := docker run $(INTEGRATION_OPTS ) $(if $(DOCKER_NON_INTERACTIVE ) , , -i) $(DOCKER_RUN_OPTS )
38
36
39
- PRE_TARGET ?= build-dev-image
37
+ IN_DOCKER ?= true
40
38
41
39
PLATFORM_URL := $(if $(PLATFORM_URL ) ,$(PLATFORM_URL ) ,"https://pilot.traefik.io")
42
40
43
41
default : binary
44
42
45
43
# # Build Dev Docker image
46
44
build-dev-image : dist
47
- docker build $(DOCKER_BUILD_ARGS ) -t " $( TRAEFIK_DEV_IMAGE) " -f build.Dockerfile .
45
+ $( if $( IN_DOCKER ) , docker build $(DOCKER_BUILD_ARGS ) -t "$(TRAEFIK_DEV_IMAGE ) " -f build.Dockerfile .,)
48
46
49
47
# # Build Dev Docker image without cache
50
48
build-dev-image-no-cache : dist
@@ -72,9 +70,13 @@ generate-webui:
72
70
docker run --rm -v " $$ PWD/webui/static" :' /src/webui/static' traefik-webui chown -R $(shell id -u) :$(shell id -g) ./static; \
73
71
fi
74
72
75
- # # Build the linux binary
76
- binary : generate-webui $(PRE_TARGET )
77
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK ) ) ./script/make.sh generate binary
73
+ # # Build the binary
74
+ binary : generate-webui build-dev-image
75
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK ) ) ./script/make.sh generate binary
76
+
77
+ # # Build the linux binary locally
78
+ binary-debug : generate-webui
79
+ GOOS=linux ./script/make.sh binary
78
80
79
81
# # Build the binary for the standard platforms (linux, darwin, windows)
80
82
crossbinary-default : generate-webui build-dev-image
@@ -86,35 +88,35 @@ crossbinary-default-parallel:
86
88
$(MAKE ) build-dev-image crossbinary-default
87
89
88
90
# # Run the unit and integration tests
89
- test : $( PRE_TARGET )
91
+ test : build-dev-image
90
92
-docker network create traefik-test-network --driver bridge --subnet 172.31.42.0/24
91
93
trap ' docker network rm traefik-test-network' EXIT; \
92
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK_TEST ) ,) ./script/make.sh generate test-unit binary test-integration
94
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK_TEST ) ,) ./script/make.sh generate test-unit binary test-integration
93
95
94
96
# # Run the unit tests
95
- test-unit : $( PRE_TARGET )
97
+ test-unit : build-dev-image
96
98
-docker network create traefik-test-network --driver bridge --subnet 172.31.42.0/24
97
99
trap ' docker network rm traefik-test-network' EXIT; \
98
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK_TEST ) ) ./script/make.sh generate test-unit
100
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK_TEST ) ) ./script/make.sh generate test-unit
99
101
100
102
# # Run the integration tests
101
- test-integration : $( PRE_TARGET )
103
+ test-integration : build-dev-image
102
104
-docker network create traefik-test-network --driver bridge --subnet 172.31.42.0/24
103
105
trap ' docker network rm traefik-test-network' EXIT; \
104
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK_TEST ) ,) ./script/make.sh generate binary test-integration
106
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK_TEST ) ,) ./script/make.sh generate binary test-integration
105
107
106
108
# # Pull all images for integration tests
107
109
pull-images :
108
110
grep --no-filename -E ' ^\s+image:' ./integration/resources/compose/* .yml | awk ' {print $$2}' | sort | uniq | xargs -P 6 -n 1 docker pull
109
111
110
112
# # Validate code and docs
111
- validate-files : $( PRE_TARGET )
112
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK ) ) ./script/make.sh generate validate-lint validate-misspell
113
+ validate-files : build-dev-image
114
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK ) ) ./script/make.sh generate validate-lint validate-misspell
113
115
bash $(CURDIR ) /script/validate-shell-script.sh
114
116
115
117
# # Validate code, docs, and vendor
116
- validate : $( PRE_TARGET )
117
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK ) ) ./script/make.sh generate validate-lint validate-misspell validate-vendor
118
+ validate : build-dev-image
119
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK ) ) ./script/make.sh generate validate-lint validate-misspell validate-vendor
118
120
bash $(CURDIR ) /script/validate-shell-script.sh
119
121
120
122
# # Clean up static directory and build a Docker Traefik image
@@ -125,6 +127,10 @@ build-image: clean-webui binary
125
127
build-image-dirty : binary
126
128
docker build -t $(TRAEFIK_IMAGE ) .
127
129
130
+ # # Locally build traefik for linux, then shove it an alpine image, with basic tools.
131
+ build-image-debug : binary-debug
132
+ docker build -t $(TRAEFIK_IMAGE ) -f debug.Dockerfile .
133
+
128
134
# # Start a shell inside the build env
129
135
shell : build-dev-image
130
136
$(DOCKER_RUN_TRAEFIK ) /bin/bash
@@ -150,17 +156,17 @@ generate-genconf:
150
156
go run ./cmd/internal/gen/
151
157
152
158
# # Create packages for the release
153
- release-packages : generate-webui $( PRE_TARGET )
159
+ release-packages : generate-webui build-dev-image
154
160
rm -rf dist
155
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK_NOTTY ) ) goreleaser release --skip-publish --timeout=" 90m"
156
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK_NOTTY ) ) tar cfz dist/traefik-${VERSION} .src.tar.gz \
161
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK_NOTTY ) ) goreleaser release --skip-publish --timeout=" 90m"
162
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK_NOTTY ) ) tar cfz dist/traefik-${VERSION} .src.tar.gz \
157
163
--exclude-vcs \
158
164
--exclude .idea \
159
165
--exclude .travis \
160
166
--exclude .semaphoreci \
161
167
--exclude .github \
162
168
--exclude dist .
163
- $(if $(PRE_TARGET ) ,$(DOCKER_RUN_TRAEFIK_NOTTY ) ) chown -R $(shell id -u) :$(shell id -g) dist/
169
+ $(if $(IN_DOCKER ) ,$(DOCKER_RUN_TRAEFIK_NOTTY ) ) chown -R $(shell id -u) :$(shell id -g) dist/
164
170
165
171
# # Format the Code
166
172
fmt :
0 commit comments