Skip to content
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

Build a docker image with greenframe-cli #19

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# syntax=docker/dockerfile:1
FROM node:16 as base

RUN apt update && apt install -y \
apt-transport-https \
bash \
ca-certificates \
curl \
git \
gnupg2 \
lsb-release \
python3 \
software-properties-common

# Install docker
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
RUN apt update && apt install -y \
containerd.io \
docker-ce \
docker-ce-cli \
docker-compose-plugin \
&& rm -rf /var/lib/apt/lists/*

# Install kubectl cli
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl

vpeltot marked this conversation as resolved.
Show resolved Hide resolved
# Install greenframe cli
RUN cd /root \
&& curl https://assets.greenframe.io/install.sh | bash
ENV PATH $PATH:/root/.local/bin

RUN mkdir /app
RUN git config --global --add safe.directory /app
WORKDIR /app


## Specific build with GCP tools
FROM base as gcp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this part related to greenframe?

Copy link
Contributor Author

@vpeltot vpeltot Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcloud command line tools are required to use kubectl ... commands in the Google Cloud Platform kubernetes execution context, especially for all authentication steps.
It's the same for Azure and AWS.

I think it would be great to offer all the necessary tools for the major cloud providers (GCP, AWS, Azure) and create a specific version of the greenframe-cli image.

I added a new make command (which can be used in the GitHub workflow) to build these images:

DOCKER_BUILDKIT=1 docker build -t greenframe-cli:latest -t greenframe-cli:$(PACKAGE_VERSION) . --target base

for the base image, and:

DOCKER_BUILDKIT=1 docker build -t greenframe-cli:$(PACKAGE_VERSION)-gcp . --target gcp 
etc ...

for the specific cloud providers.

One greenframe-cli version will have these docker version:

  • greenframe-cli:latest
  • greenframe-cli:1.4.4
  • greenframe-cli:1.4.4-gcp
  • greenframe-cli:1.4.4-azure
  • greenframe-cli:1.4.4-...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not something we want to maintain in this repository. I prefer that we provide a cloud-agnostic base image, and leave to the community the cloud-specific images.

RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
RUN mkdir -p /usr/local/gcloud \
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& /usr/local/gcloud/google-cloud-sdk/install.sh
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin
RUN gcloud components install gke-gcloud-auth-plugin
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ upload-installation-scripts: ## Publish on the bucket installion bash scripts
promote-production: upload-installation-scripts ## Publish uploaded tarballs on a stable channel
npx oclif promote --version $(PACKAGE_VERSION) --sha $(SHORT_HASH) -t $(DEPLOY_TARGETS) && yarn set version stable

create-docker-image: ## Create a docker image with the latest published version
DOCKER_BUILDKIT=1 docker build -t greenframe-cli:latest -t greenframe-cli:$(PACKAGE_VERSION) . --target base
DOCKER_BUILDKIT=1 docker build -t greenframe-cli:$(PACKAGE_VERSION)-gcp . --target gcp

test: test-unit test-e2e ## Launch all tests

test-unit: ## Launch unit test
Expand Down