Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Merge pull request hypnoglow#88 from hypnoglow/add-docker-image
Browse files Browse the repository at this point in the history
Add docker image
  • Loading branch information
hypnoglow authored Nov 4, 2019
2 parents 7fe58e8 + 7d0b698 commit f6299a6
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 1 deletion.
102 changes: 102 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,47 @@
# Ref: https://circleci.com/docs/2.0/configuration-reference/
version: 2.1

commands:
build_push_docker_image:
description: "Builds and pushes Docker image"
parameters:
helm_version:
type: string
image_name:
type: string
default: hypnoglow/helm-s3
steps:
- run:
name: Build & push Docker image
command: |
HELM_VERSION="<< parameters.helm_version >>"
IMAGE_NAME="<< parameters.image_name >>"
PLUGIN_VERSION="commit.${CIRCLE_SHA1}"
if [ "${CIRCLE_BRANCH}" == "master" ]; then
PLUGIN_VERSION="master"
fi
if [ -n "${CIRCLE_TAG}" ]; then
PLUGIN_VERSION="${CIRCLE_TAG#v*}"
fi
docker build \
--build-arg HELM_VERSION=${HELM_VERSION} \
--build-arg PLUGIN_VERSION=${PLUGIN_VERSION} \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
-t ${IMAGE_NAME}:local .
echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
IMAGE_TAG="${PLUGIN_VERSION}-helm${HELM_VERSION}"
docker tag ${IMAGE_NAME}:local ${IMAGE_NAME}:${IMAGE_TAG}
docker push ${IMAGE_NAME}:${IMAGE_TAG}
IMAGE_TAG_HELM_MINOR="${PLUGIN_VERSION}-helm${HELM_VERSION%*.*}"
docker tag ${IMAGE_NAME}:local ${IMAGE_NAME}:${IMAGE_TAG_HELM_MINOR}
docker push ${IMAGE_NAME}:${IMAGE_TAG_HELM_MINOR}
jobs:
dep:
docker:
Expand Down Expand Up @@ -119,6 +160,28 @@ jobs:
if [ -n "$CIRCLE_TAG" ]; then
curl -sL https://git.io/goreleaser | bash
fi
docker-helm-2_14:
docker:
- image: circleci/buildpack-deps:stretch
working_directory: ~/workspace/helm-s3
steps:
- attach_workspace:
at: ~/workspace
- setup_remote_docker:
version: 18.06.0-ce
- build_push_docker_image:
helm_version: 2.14.3
docker-helm-2_15:
docker:
- image: circleci/buildpack-deps:stretch
working_directory: ~/workspace/helm-s3
steps:
- attach_workspace:
at: ~/workspace
- setup_remote_docker:
version: 18.06.0-ce
- build_push_docker_image:
helm_version: 2.15.2

workflows:
version: 2
Expand All @@ -138,6 +201,24 @@ workflows:
filters:
branches:
only: master
- docker-helm-2_14:
requires:
- dep
- test-unit
- test-integration-and-e2e
- test-install
filters:
branches:
only: master
- docker-helm-2_15:
requires:
- dep
- test-unit
- test-integration-and-e2e
- test-install
filters:
branches:
only: master
# release-pipeline runs only on tags.
release-pipeline:
jobs:
Expand All @@ -155,9 +236,30 @@ workflows:
only: /.*/
branches:
ignore: /.*/
- docker-helm-2_14:
requires:
- dep
- test-install
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- docker-helm-2_15:
requires:
- dep
- test-install
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- release:
requires:
- dep
- test-install
- docker-helm-2_14
- docker-helm-2_15
filters:
tags:
only: /.*/
Expand Down
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ref: https://docs.docker.com/engine/reference/builder/#dockerignore-file
.git
bin
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- The plugin is now also distributed as Docker images. Images are pushed to Docker Hub tagged with plugin release
version and suffixed with Helm version. The image built from master branch is also available, note that it should be
only used for playing and testing, it is **strongly discouraged** to use that image for production use cases.
Refer to https://hub.docker.com/r/hypnoglow/helm-s3 for details and all available tags.
[Refs: [#79](https://github.com/hypnoglow/helm-s3/issues/79) [#88](https://github.com/hypnoglow/helm-s3/pull/88)]

### Fixed

- Fixed incorrect s3 url when "proxy" runs on uninitialized repository.
Expand Down
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ARG HELM_VERSION

FROM golang:1.12-alpine as build

ARG PLUGIN_VERSION

WORKDIR /workspace/helm-s3

COPY . .

RUN apk add --no-cache git

RUN go build -o bin/helms3 \
-mod=vendor \
-ldflags "-X main.version=${PLUGIN_VERSION}" \
./cmd/helms3

# Correct the plugin manifest with docker-specific fixes:
# - remove hooks, because we are building everything locally from source
# - update version
RUN sed "/^hooks:/,+2 d" plugin.yaml > plugin.yaml.fixed \
&& sed -i "s/^version:.*$/version: ${PLUGIN_VERSION}/" plugin.yaml.fixed

FROM alpine/helm:${HELM_VERSION}

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
ARG PLUGIN_VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="helm-s3" \
org.label-schema.description="The Helm plugin that provides S3 protocol support and allows to use AWS S3 as a chart repository." \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/hypnoglow/helm-s3" \
org.label-schema.version=$PLUGIN_VERSION \
org.label-schema.schema-version="1.0"

COPY --from=build /workspace/helm-s3/plugin.yaml.fixed /root/.helm/cache/plugins/helm-s3/plugin.yaml
COPY --from=build /workspace/helm-s3/bin/helms3 /root/.helm/cache/plugins/helm-s3/bin/helms3

RUN mkdir -p /root/.helm/plugins \
&& helm plugin install /root/.helm/cache/plugins/helm-s3

ENTRYPOINT []
CMD []
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ download versioned release with prebuilt binary from [github releases](https://g
However, if you want to build the plugin from source, or you want to contribute
to the plugin, please see [these instructions](.github/CONTRIBUTING.md).

#### Note on AWS authentication
### Docker Images

[![Docker Pulls](https://img.shields.io/docker/pulls/hypnoglow/helm-s3)](https://hub.docker.com/r/hypnoglow/helm-s3)

The plugin is also distributed as Docker images. Images are pushed to Docker Hub tagged with plugin release
version and suffixed with Helm version. The image built from master branch is also available, note that it should be
only used for playing and testing, it is **strongly discouraged** to use that image for production use cases.
Refer to https://hub.docker.com/r/hypnoglow/helm-s3 for details and all available tags.

### Note on AWS authentication

Because this plugin assumes private access to S3, you need to provide valid AWS credentials.
You can do this in [the same manner](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) as for `AWS CLI` tool.
Expand Down

0 comments on commit f6299a6

Please # to comment.