Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
build: update build files for v2
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Hung <chris@iotechsys.com>
  • Loading branch information
Chris Hung committed Apr 29, 2021
1 parent ac673e8 commit 6aec653
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 IOTech Ltd
# Copyright (c) 2020-2021 IOTech Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

ARG BASE=golang:1.15-alpine3.12
FROM ${BASE} AS builder
ARG ALPINE_PKG_BASE="build-base git openssh-client"
ARG ALPINE_PKG_BASE="make git openssh-client gcc libc-dev zeromq-dev libsodium-dev"
ARG ALPINE_PKG_EXTRA=""

# Replicate the APK repository override.
Expand All @@ -25,24 +25,28 @@ RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/reposi
# Install our build time packages.
RUN apk add --update --no-cache ${ALPINE_PKG_BASE} ${ALPINE_PKG_EXTRA}

WORKDIR $GOPATH/src/github.com/edgexfoundry/device-random
WORKDIR /device-random

COPY . .

RUN go mod download

# To run tests in the build container:
# docker build --build-arg 'MAKE=build test' .
# This is handy of you do your Docker business on a Mac
ARG MAKE='make build'
RUN $MAKE

FROM alpine
FROM alpine:3.12

# dumb-init needed for injected secure bootstrapping entrypoint script when run in secure mode.
RUN apk add --update --no-cache zeromq dumb-init

ENV APP_PORT=49988
EXPOSE $APP_PORT
COPY --from=builder /device-random/cmd /
COPY --from=builder /device-random/LICENSE /
COPY --from=builder /device-random/Attribution.txt /

COPY --from=builder /go/src/github.com/edgexfoundry/device-random/cmd /
COPY --from=builder /go/src/github.com/edgexfoundry/device-random/LICENSE /
COPY --from=builder /go/src/github.com/edgexfoundry/device-random/Attribution.txt /
EXPOSE 49988

ENTRYPOINT ["/device-random"]
CMD ["--cp=consul://edgex-core-consul:8500", "--confdir=/res", "--registry"]
6 changes: 3 additions & 3 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 IOTech Ltd
# Copyright (c) 2020-2021 IOTech Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,10 +18,10 @@ ARG BASE=golang:1.15-alpine3.12
FROM ${BASE}

LABEL license='SPDX-License-Identifier: Apache-2.0' \
copyright='Copyright (c) 2020: IOTech'
copyright='Copyright (c) 2020-2021: IOTech'

RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories
RUN apk add --update --no-cache make git openssh build-base
RUN apk add --update --no-cache make git openssh gcc libc-dev zeromq-dev libsodium-dev

# set the working directory
WORKDIR /device-random
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: build test clean prepare update docker

GO = CGO_ENABLED=0 GO111MODULE=on go
GOCGO = CGO_ENABLED=1 GO111MODULE=on go

MICROSERVICES=cmd/device-random

Expand All @@ -14,14 +15,14 @@ GIT_SHA=$(shell git rev-parse HEAD)
GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-random.Version=$(VERSION)"

build: $(MICROSERVICES)
$(GO) build ./...
$(GOCGO) build ./...

cmd/device-random:
$(GO) build $(GOFLAGS) -o $@ ./cmd
$(GOCGO) build $(GOFLAGS) -o $@ ./cmd

test:
$(GO) test ./... -coverprofile=coverage.out
$(GO) vet ./...
$(GOCGO) test ./... -coverprofile=coverage.out
$(GOCGO) vet ./...
gofmt -l .
[ "`gofmt -l .`" = "" ]
./bin/test-attribution-txt.sh
Expand Down

0 comments on commit 6aec653

Please sign in to comment.