diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7752595..cf14d92 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -150,6 +150,16 @@ jobs: AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} + - name: ⚙️ Build docker image + run: make build-docker-image + + - name: 🚀 Push docker image + run: make push-docker-image + if: ${{ github.ref == 'refs/heads/production' }} + env: + DOCKER_REGISTRY_USER: ${{secrets.DOCKER_REGISTRY_USER}} + DOCKER_REGISTRY_PASS: ${{secrets.DOCKER_REGISTRY_PASS}} + - name: 📜 Update readme uses: stefanzweifel/git-auto-commit-action@v4 with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a48c8d9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# 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 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 + +ENTRYPOINT ["greenframe"] +CMD ["--version"] \ No newline at end of file diff --git a/Makefile b/Makefile index 69c67cc..ca12fa4 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,15 @@ 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 +build-docker-image: ## Create a docker image with the latest published version + docker build -t marmelab/greenframe . + +push-docker-image: ## Tag & push the docker image to the docker hub registry + docker login + docker tag marmelab/greenframe marmelab/greenframe:latest + docker tag marmelab/greenframe marmelab/greenframe:$(PACKAGE_VERSION) + docker push marmelab/greenframe:latest marmelab/greenframe:$(PACKAGE_VERSION) + test: test-unit test-e2e ## Launch all tests test-unit: ## Launch unit test diff --git a/README.md b/README.md index ee9e5ee..19b799c 100644 --- a/README.md +++ b/README.md @@ -341,6 +341,19 @@ DESCRIPTION _See code: [dist/commands/update.ts](https://github.com/marmelab/greenframe-cli/blob/v1.5.0/dist/commands/update.ts)_ +## Docker + +From version 1.5.1, the command line tool can be used in a docker container. + +``` + $ docker run marmelab/greenframe --help +``` +``` + $ docker run marmelab/greenframe [COMMAND] +``` + +[All previous described commands](#commands) are available in the docker image. + ## License GreenFrame is licensed under the [Elastic License v2.0](https://www.elastic.co/licensing/elastic-license).