Skip to content
This repository was archived by the owner on Jan 12, 2023. It is now read-only.

Commit c57f770

Browse files
committed
Add evicter to docker image
1 parent 32d5657 commit c57f770

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
k-rail
2-
vendor
1+
/k-rail
2+
/evicter
3+
vendor

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Build stage
22
ARG GO_VERSION=1.13
3-
FROM golang:${GO_VERSION}-alpine AS builder
4-
RUN mkdir build; apk --no-cache add ca-certificates git make
3+
FROM golang:${GO_VERSION}-alpine3.10 AS builder
4+
RUN mkdir build ; apk --no-cache add ca-certificates git make
55
WORKDIR /go/src/github.com/cruise-automation/k-rail
66
COPY ./ /build/
7-
RUN cd /build; make test; make build
7+
RUN cd /build; make clean; make test; make build
88

99
# Production image build stage
1010
FROM scratch
1111
EXPOSE 8443/tcp
1212
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
13-
COPY --from=builder /etc/passwd /etc/passwd
1413
COPY --from=builder /build/k-rail /k-rail
14+
COPY --from=builder /build/evicter /evicter
1515
USER 65534
1616
ENTRYPOINT ["/k-rail", "-config", "/config/config.yml"]

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12+
.PHONY: all build test image clean
1213

13-
ensure:
14-
dep ensure
14+
LDFLAGS = -extldflags=-static -s -w
15+
BUILD_FLAGS = -mod=readonly -ldflags '$(LDFLAGS)' -trimpath
16+
BUILD_VERSION ?= manual
17+
IMAGE_NAME = "cruise/k-rail:${BUILD_VERSION}"
18+
19+
all: dist
20+
21+
dist: image
22+
23+
clean:
24+
rm -f evicter k-rail
1525

1626
build:
17-
GO111MODULE=on CGO_ENABLED=0 go build -o k-rail cmd/main.go
27+
GO111MODULE=on CGO_ENABLED=0 go build ${BUILD_FLAGS} -o k-rail cmd/k-rail/main.go
28+
GO111MODULE=on CGO_ENABLED=0 go build ${BUILD_FLAGS} -o evicter cmd/evicter/*.go
1829

1930
test:
20-
GO111MODULE=on CGO_ENABLED=1 go test -race -cover $(shell go list ./... | grep -v /vendor/)
21-
31+
GO111MODULE=on CGO_ENABLED=1 go test -mod=readonly -race ./...
32+
33+
image:
34+
docker build --pull -t $(IMAGE_NAME) .
File renamed without changes.

0 commit comments

Comments
 (0)