Skip to content

Commit

Permalink
Fix Dockerfile builds
Browse files Browse the repository at this point in the history
Simplify `Dockerfile` content by removing obsolete componentes.

Switch to GoReleaser builds.
  • Loading branch information
HeavyWombat committed Jul 5, 2021
1 parent cd7465d commit 6f11c25
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 76 deletions.
66 changes: 27 additions & 39 deletions Build-System.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,29 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM golang:1.16 AS build

RUN GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt && \
git clone https://github.com/direnv/direnv $GOPATH/src/github.com/direnv/direnv && \
cd $GOPATH/src/github.com/direnv/direnv && \
make install

RUN go get -d github.com/SUSE/stampy && \
cd $GOPATH/src/github.com/SUSE/stampy && \
find . -type f -print0 | xargs -0 perl -pi -e 's:github.com/golang/lint/golint:golang.org/x/lint/golint:g' && \
make tools && \
make all && \
mv $GOPATH/src/github.com/SUSE/stampy/build/linux-amd64/stampy /usr/local/bin/stampy


FROM ubuntu:xenial

# Place shfmt into Docker image
COPY --from=build /go/bin/shfmt /usr/local/bin/shfmt

# Place stampy into Docker image
COPY --from=build /usr/local/bin/stampy /usr/local/bin/stampy

# Place direnv into Docker image
COPY --from=build /usr/local/bin/direnv /usr/local/bin/direnv
RUN echo 'eval "$(direnv hook bash)"' >> ~/.bashrc

# Update to latest and install required tools
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update > /dev/null && \
RUN apt-get update >/dev/null && \
apt-get upgrade -y > /dev/null && \
apt-get install -y \
build-essential \
curl \
git-core \
jq \
vim \
wget \
build-essential \
curl \
git-core \
jq \
vim \
wget \
>/dev/null && \
rm -rf /var/lib/apt/lists/*

# Install docker
RUN apt-get update > /dev/null && \
RUN apt-get update >/dev/null && \
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
>/dev/null && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
Expand All @@ -78,5 +53,18 @@ RUN curl --progress-bar --location https://storage.googleapis.com/golang/go1.16.
ENV GOPATH=/go
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

# Install latest Spruce
RUN curl --silent --location "https://github.com/geofffranks/spruce/releases/download/$(curl --silent --location "https://api.github.com/repos/geofffranks/spruce/releases/latest" | jq -r .tag_name)/spruce-linux-amd64" > /usr/bin/spruce && chmod a+rx /usr/bin/spruce
# Install Spruce
RUN SPRUCE_VERSION="$(curl --silent --location "https://api.github.com/repos/geofffranks/spruce/releases/latest" | jq -r .tag_name)" && \
curl --silent --location "https://github.com/geofffranks/spruce/releases/download/${SPRUCE_VERSION}/spruce-linux-amd64" --output /usr/bin/spruce && \
chmod a+rx /usr/bin/spruce

# Install shfmt
RUN SHFTM_VERSION="$(curl --silent --location "https://api.github.com/repos/mvdan/sh/releases/latest" | jq -r .tag_name)" && \
curl --silent --location "https://github.com/mvdan/sh/releases/download/${SHFTM_VERSION}/shfmt_${SHFTM_VERSION}_linux_amd64" --output /usr/bin/shfmt && \
chmod a+rx /usr/bin/shfmt

# Install direnv
RUN DIRENV_VERSION="$(curl --silent --location "https://api.github.com/repos/direnv/direnv/releases/latest" | jq -r .tag_name)" && \
curl --silent --location "https://github.com/direnv/direnv/releases/download/${DIRENV_VERSION}/direnv.linux-amd64" --output /usr/bin/direnv && \
chmod a+rx /usr/bin/direnv && \
echo 'eval "$(direnv hook bash)"' >>$HOME/.bashrc
20 changes: 5 additions & 15 deletions Havener-Alpine.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@

FROM golang:1.16-alpine AS build
COPY . /go/src/github.com/homeport/havener
RUN apk add --update make git bash file curl jq && \
RUN apk add --update git curl && \
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh && \
cd /go/src/github.com/homeport/havener && \
make build && \
cp -p binaries/havener-linux-amd64 /usr/local/bin/havener
goreleaser build --rm-dist --skip-validate --single-target && \
cp -p dist/havener_linux_amd64/havener /usr/local/bin/havener


FROM alpine:3
FROM alpine

# Update to latest and install required tools
RUN apk update && \
Expand All @@ -41,15 +42,4 @@ RUN apk update && \
vim && \
rm -rf /var/cache/apk/*

# Install (minimal) IBM Cloud CLI
RUN curl --silent --location https://clis.ng.bluemix.net/install/linux | sh && \
bx plugin install container-service -r Bluemix && \
bx plugin install container-registry -r Bluemix && \
bx config --usage-stats-collect false && \
bx config --check-version false

# Install latest kubectl
RUN curl --progress-bar --location "https://storage.googleapis.com/kubernetes-release/release/$(curl --silent --location https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" > /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl

COPY --from=build /usr/local/bin/havener /usr/local/bin/havener
33 changes: 11 additions & 22 deletions Havener-Ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,24 @@

FROM golang:1.16 AS build
COPY . /go/src/github.com/homeport/havener
RUN apt-get update >/dev/null && \
apt-get install -y file jq >/dev/null && \
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh && \
cd /go/src/github.com/homeport/havener && \
make build && \
cp -p binaries/havener-linux-amd64 /usr/local/bin/havener
goreleaser build --rm-dist --skip-validate --single-target && \
cp -p dist/havener_linux_amd64/havener /usr/local/bin/havener


FROM ubuntu:xenial
FROM ubuntu

# Update to latest and install required tools
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
dnsutils \
curl \
git \
jq \
vim && \
apt-get install --no-install-recommends -y \
dnsutils \
curl \
git \
jq \
vim && \
rm -rf /var/lib/apt/lists/*

# Install (minimal) IBM Cloud CLI
RUN curl --silent --location https://clis.ng.bluemix.net/install/linux | sh && \
bx plugin install container-service -r Bluemix && \
bx plugin install container-registry -r Bluemix && \
bx config --usage-stats-collect false && \
bx config --check-version false

# Install latest kubectl
RUN curl --progress-bar --location "https://storage.googleapis.com/kubernetes-release/release/$(curl --silent --location https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" > /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl

COPY --from=build /usr/local/bin/havener /usr/local/bin/havener

0 comments on commit 6f11c25

Please sign in to comment.