Add Dockerfile for steampipe and automated image deploy. Closes #662. Closes #677

This commit is contained in:
Binaek Sarkar
2021-07-30 03:06:49 +05:30
committed by GitHub
parent 38665a78f1
commit fbfebd0db8
4 changed files with 101 additions and 5 deletions

46
.github/workflows/publish_docker.yml vendored Normal file
View File

@@ -0,0 +1,46 @@
name: Publish Docker Release
on:
workflow_dispatch:
inputs:
release:
description: "The name of the released version to publish"
required: true
env:
STEAMPIPE_VERSION: ${{ github.event.inputs.release }}
jobs:
publish_docker:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Clean Version for Tag
id: generate_docker_tag
run: |
echo "::set-output name=docker_tag::${STEAMPIPE_VERSION#"v"}"
- name: Build and Push to Docker Hub
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
build-args: |
TARGETOS=linux
TARGETARCH=amd64
TARGETVERSION=${{ env.STEAMPIPE_VERSION }}
tags: |
turbot/steampipe:${{ steps.generate_docker_tag.outputs.docker_tag }}
turbot/steampipe:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@@ -3,10 +3,10 @@ on:
workflow_dispatch:
inputs:
branch:
description: 'The branch that will be built'
description: "The branch that will be built"
required: true
tag:
description: 'The release tag that will be set'
description: "The release tag that will be set"
required: true
env:
@@ -16,7 +16,7 @@ jobs:
goreleaser:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -70,10 +70,9 @@ jobs:
needs: goreleaser
strategy:
matrix:
platform: [ ubuntu-latest ]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:

39
Dockerfile Normal file
View File

@@ -0,0 +1,39 @@
FROM debian:buster-slim
LABEL maintainer="Turbot Support <help@turbot.com>"
ARG TARGETVERSION
ARG TARGETOS
ARG TARGETARCH
# 'wget' for downloading steampipe, 'less' for paging in the UI
RUN apt-get update -y \
&& apt-get install -y wget less \
&& adduser --system --disabled-login --ingroup 0 --gecos "steampipe user" --shell /bin/false --uid 9193 steampipe
# downlaod the published image
RUN echo \
&& cd /tmp \
&& wget -nv https://github.com/turbot/steampipe/releases/download/${TARGETVERSION}/steampipe_${TARGETOS}_${TARGETARCH}.tar.gz \
&& tar xzf steampipe_${TARGETOS}_${TARGETARCH}.tar.gz \
&& mv steampipe /usr/local/bin/ \
&& rm -rf /tmp/steampipe_${TARGETOS}_${TARGETARCH}.tar.gz
# Change user to non-root
USER steampipe:0
# Use a constant workspace directory that can be mounted to
WORKDIR /workspace
# disable auto-update
ENV STEAMPIPE_UPDATE_CHECK=false
# Run --version
RUN steampipe --version
# Run steampipe query to install db and fdw (they are installed on the first run)
RUN steampipe query "select * from steampipe_mod"
EXPOSE 9193
COPY docker-entrypoint.sh /usr/local/bin
ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "steampipe"]

12
docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -Eeo pipefail
chown steampipe:0 /home/steampipe/.steampipe/db/12.1.0/data/
# if first arg is anything other than `steampipe`, assume we want to run steampipe
# this is for when other commands are passed to the container
if [ "${1:0}" != 'steampipe' ]; then
set -- steampipe "$@"
fi
exec "$@"