Skip to content

Commit a7d83be

Browse files
author
Cheng Pan
committed
Switch to use multi stage build for container
Remove binary build in ci_e2e_test.sh
1 parent 5819016 commit a7d83be

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
*
21
!server

Dockerfile

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
FROM amazonlinux:2 as amazonlinux
1514

15+
FROM golang:1.12.7-stretch as builder
16+
WORKDIR /go/src/github.com/kubernetes-sigs/aws-alb-ingress-controller/
17+
COPY . .
18+
RUN make server
19+
20+
FROM amazonlinux:2 as amazonlinux
1621
FROM scratch
1722
COPY --from=amazonlinux /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/
18-
COPY server server
23+
COPY --from=builder /go/src/github.com/kubernetes-sigs/aws-alb-ingress-controller/server server
1924
ENTRYPOINT ["/server"]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ LDFLAGS=-X $(PKG)/version.COMMIT=$(GIT_COMMIT) -X $(PKG)/version.RELEASE=$(TAG)
3838
server: cmd/main.go
3939
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -a -installsuffix cgo -ldflags '-s -w $(LDFLAGS)' -o server ./cmd
4040

41-
container: server
41+
container:
4242
docker build --pull -t $(PREFIX):$(TAG) .
4343

4444
push:

scripts/ci_e2e_test.sh

+1-8
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ build_push_controller_image() {
128128
return 1
129129
fi
130130

131-
echo "Building aws-alb-ingress-controller binary"
132-
make clean && make server
133-
if [[ $? -ne 0 ]]; then
134-
echo "Unable to build aws-alb-ingress-controller binary" >&2
135-
return 1
136-
fi
137-
138131
echo "Building aws-alb-ingress-controller image"
139132
if ! docker build -t "$CONTROLLER_IMAGE_NAME" ./; then
140133
echo "Unable to build aws-alb-ingress-controller image" >&2
@@ -203,4 +196,4 @@ main() {
203196
test $cluster_name
204197
}
205198

206-
main $@
199+
main $@

0 commit comments

Comments
 (0)