Skip to content

Commit

Permalink
Update Candid dockerfile (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Aug 29, 2023
1 parent b3c4436 commit 28582ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
26 changes: 9 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
# syntax=docker/dockerfile:1.3.1
FROM ubuntu:20.04 AS build
SHELL ["/bin/bash", "-c"]
ENV GVM_VERSION=master
COPY ./go.mod ./go.mod
RUN apt-get update && \
apt-get -y install gcc bison binutils make git gcc curl build-essential mercurial ca-certificates
RUN bash < <(curl -SL -v https://raw.githubusercontent.com/moovweb/gvm/${GVM_VERSION}/binscripts/gvm-installer) && \
source /root/.gvm/scripts/gvm && \
gvm install go$(cat go.mod | sed -n "/^go/p" | cut -d ' ' -f 2) -B && \
gvm use go$(cat go.mod | sed -n "/^go/p" | cut -d ' ' -f 2) --default

FROM build as build-env
FROM ubuntu:20.04 as build-env
ARG GIT_COMMIT
ARG VERSION
ARG GO_VERSION
WORKDIR /usr/src/candid
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install wget git -y
RUN wget -L "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz"
RUN tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
ENV PATH="${PATH}:/usr/local/go/bin"
COPY . .
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && ./scripts/set-version.sh
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go mod vendor
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && GOBIN=/usr/src/candid go install gopkg.in/macaroon-bakery.v2/cmd/bakery-keygen@latest
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -o candidsrv -race -v -a -mod vendor ./cmd/candidsrv
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -o candid -race -v -a -mod vendor ./cmd/candid
RUN go build -o candidsrv -v ./cmd/candidsrv
RUN go build -o candid -v ./cmd/candid
RUN GOBIN=/usr/src/candid go install gopkg.in/macaroon-bakery.v2/cmd/bakery-keygen@latest

# Define a smaller single process image for deployment
FROM ubuntu:20.04 AS deploy-env
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

GIT_COMMIT := $(shell git rev-parse --verify HEAD)
GIT_VERSION := $(shell git describe --dirty)
GO_VERSION := $(shell go list -f {{.GoVersion}} -m)
ARCH := $(shell dpkg --print-architecture)

DEPENDENCIES := build-essential bzr
Expand Down Expand Up @@ -71,7 +72,9 @@ endif
image:
DOCKER_BUILDKIT=1 \
docker build \
--cache-from candid:latest \
--build-arg="GIT_COMMIT=$(GIT_COMMIT)" \
--build-arg="VERSION=$(GIT_VERSION)" \
--build-arg="GO_VERSION=$(GO_VERSION)" \
. -f ./Dockerfile -t candid

help:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ require (
sigs.k8s.io/yaml v1.2.0 // indirect
)

go 1.18
go 1.20

0 comments on commit 28582ec

Please sign in to comment.