-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dockerfile for JIMM image #1033
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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/jimm | ||
SHELL ["/bin/bash", "-c"] | ||
COPY . . | ||
RUN apt update && apt install wget gcc -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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't there more envs we need to setup? Or is this just it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's it |
||
RUN echo "${GIT_COMMIT}" | tee ./version/commit.txt | ||
RUN echo "${VERSION}" | tee ./version/version.txt | ||
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go mod vendor | ||
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -tags version -o jimmsrv -v -a -mod vendor ./cmd/jimmsrv | ||
RUN go build -tags version -o jimmsrv -v ./cmd/jimmsrv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasthinking about if we need to vendor and tbh glad you removed it, modules kinda make it redundant |
||
|
||
# Define a smaller single process image for deployment | ||
FROM ${DOCKER_REGISTRY}ubuntu:20.04 AS deploy-env | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can read this from gomod, why explicitly pass as arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're reading from go.mod in the Makefile then passing that here, I guess I was just following the same ideas as version and git commit. Should I change it to read from the go.mod inside the dockerfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind but it's an extra dependency on the makefile when it can be handled in dockerfile, up to you really (personally I'd just do it in docker file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just leave it like this, easy tweak if needed in the future.