Skip to content

Commit

Permalink
Add Dockerfile (#11)
Browse files Browse the repository at this point in the history
* reorg dockerfile

* Document multi-stage build process
  • Loading branch information
osterman authored Jun 15, 2018
1 parent 152663c commit f0cd280
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git
.gitignore
.editorconfig
**/.terraform
*.tfstate
*.tfstate.*
.idea
*.iml
.build-harness
build-harness
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Override for Makefile
[{Makefile, makefile, GNUmakefile}]
indent_style = tab
indent_size = 4

[Makefile.*]
indent_style = tab
indent_size = 4

[shell]
indent_style = tab
indent_size = 4

[*.sh]
indent_style = tab
indent_size = 4
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.build-harness
build-harness
.terraform
*.tfstate
*.tfstate.*
.idea
*.iml
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:3.7
ENV INSTALL_PATH=/packages/bin
ENV PATH=${INSTALL_PATH}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN mkdir -p ${INSTALL_PATH}
RUN apk add --update --no-cache make curl coreutils libc6-compat
ADD . /packages
RUN make -C /packages/install/ all
WORKDIR /opt
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export DOCKER_ORG ?= cloudposse
export DOCKER_IMAGE ?= $(DOCKER_ORG)/packages
export DOCKER_TAG ?= latest
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
export DOCKER_BUILD_FLAGS =

-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)

all: init deps build install run

deps:
@exit 0

build:
@make --no-print-directory docker:build

push:
docker push $(DOCKER_IMAGE)

run:
docker run -it ${DOCKER_IMAGE_NAME} sh
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ Install to a specific folder:
make -C install aws-vault INSTALL_PATH=/usr/bin
```

Add this to a `Dockerfile` to easily install packages:
Add this to a `Dockerfile` to install packages using a multi-stage build process:
```
FROM cloudposse/packages:latest AS packages
COPY --from=packages /packages/bin/kubectl /usr/local/bin/
```

Or... add this to a `Dockerfile` to easily install packages on-demand:
```
RUN git clone --depth=1 -b master https://github.com/cloudposse/packages.git /packages && \
rm -rf /packages/.git && \
Expand Down
90 changes: 90 additions & 0 deletions codefresh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Build a service with environment variables
version: '1.0'

steps:
init_variables:
title: Init variables
image: alpine
commands:
- cf_export BUILD_HARNESS_VERSION=0.5.5
- cf_export GIT_BRANCH=${{CF_BRANCH}}

build_image:
title: Build image
type: build
description: Build packages
image_name: packages
dockerfile: Dockerfile

semver:
title: Export semantic version
image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}}
working_directory: ${{build_image}}
commands:
- make git/show
- make semver/show
- make semver/export >> ${{CF_VOLUME_PATH}}/env_vars_to_export

push_image_commit:
title: Push image with commit based semver tags
type: push
candidate: ${{build_image}}
tags:
- "${{SEMVERSION_COMMIT_SHORT}}"

push_image_branch:
title: Push image with branch based semver tags
type: push
candidate: ${{build_image}}
tags:
- "${{SEMVERSION_BRANCH_COMMIT_SHORT}}"
when:
condition:
all:
executeForBranch: "'${{SEMVERSION_BRANCH}}' != ''"

push_image_tag_to_cfcr:
title: Push image with tag based semver tags
type: push
registry: cfcr
candidate: ${{build_image}}
tag: "${{SEMVERSION_TAG}}"
when:
condition:
all:
executeForTag: "'${{SEMVERSION_TAG}}' != ''"

push_image_tag_to_dockerhub:
title: Push image with tag based semver tags
type: push
registry: dockerhub
image_name: cloudposse/packages
candidate: ${{build_image}}
tag: "${{SEMVERSION_TAG}}"
when:
condition:
all:
executeForTag: "'${{SEMVERSION_TAG}}' != ''"

push_image_latest_to_cfcf:
title: Push image with latest tag
type: push
registry: cfcr
candidate: ${{build_image}}
tag: latest
when:
condition:
all:
executeForMasterBranch: "'${{CF_BRANCH}}' == 'master'"

push_image_latest_to_dockerhub:
title: Push image with latest tag
type: push
registry: dockerhub
image_name: cloudposse/packages
candidate: ${{build_image}}
tag: latest
when:
condition:
all:
executeForMasterBranch: "'${{CF_BRANCH}}' == 'master'"

0 comments on commit f0cd280

Please sign in to comment.