Skip to content

Instantly share code, notes, and snippets.

@jobwat
Created January 24, 2017 05:29
Show Gist options
  • Save jobwat/5b74686b7629604c73e5bd689b72f0cc to your computer and use it in GitHub Desktop.
Save jobwat/5b74686b7629604c73e5bd689b72f0cc to your computer and use it in GitHub Desktop.
Codeship demo case: write CI environment variables to file in image
# codeship-services.yml
revision:
build:
image: rev
dockerfile_path: ./Dockerfile-revision
volumes:
- ./data:/data
app:
build:
image: app
dockerfile_path: ./Dockerfile-app
# codeship-steps.yml
- name: Set build version in local file data/BUILD_REV
service: revision
command: write_build_rev
- name: Build app
service: app
command: /bin/true
FROM busybox
COPY data/BUILD_REV /
FROM busybox
RUN mkdir /data
COPY write_build_rev bin/
⚡ jet steps
{StepStarted=step_name:"Set build version in local file data/BUILD_REV"}
{BuildImageStarted=image_name:"rev" service_name:"revision"}
{BuildImageStdout=image_name:"rev" service_name:"revision"}: Step 1 : FROM busybox
{BuildImageStdout=image_name:"rev" service_name:"revision"}: ---> 7968321274dc
{BuildImageStdout=image_name:"rev" service_name:"revision"}: Step 2 : RUN mkdir /data
{BuildImageStdout=image_name:"rev" service_name:"revision"}: ---> Using cache
{BuildImageStdout=image_name:"rev" service_name:"revision"}: ---> 30337c708d45
{BuildImageStdout=image_name:"rev" service_name:"revision"}: Step 3 : COPY write_build_rev bin/
{BuildImageStdout=image_name:"rev" service_name:"revision"}: ---> Using cache
{BuildImageStdout=image_name:"rev" service_name:"revision"}: ---> c107c054ba1f
{BuildImageStdout=image_name:"rev" service_name:"revision"}: Successfully built c107c054ba1f
{BuildImageFinished=image_name:"rev" service_name:"revision"}
{ContainerRunStdout=step_name:"Set build version in local file data/BUILD_REV" service_name:"revision"}: Writing '2017-01-24 05:24:50.360018412 +0000 UTC' to file /data/BUILD_REV
{StepFinished=step_name:"Set build version in local file data/BUILD_REV" type:STEP_FINISHED_TYPE_SUCCESS}
{StepStarted=step_name:"Build app"}
{BuildImageStarted=image_name:"app" service_name:"app"}
{BuildImageStdout=image_name:"app" service_name:"app"}: Step 1 : FROM busybox
{BuildImageStdout=image_name:"app" service_name:"app"}: ---> 7968321274dc
{BuildImageStdout=image_name:"app" service_name:"app"}: Step 2 : COPY data/BUILD_REV /
{BuildImageStdout=image_name:"app" service_name:"app"}: ---> c5df86199db2
{BuildImageStdout=image_name:"app" service_name:"app"}: Removing intermediate container 24b62c75605f
{BuildImageStdout=image_name:"app" service_name:"app"}: Successfully built c5df86199db2
{BuildImageFinished=image_name:"app" service_name:"app"}
{StepFinished=step_name:"Build app" type:STEP_FINISHED_TYPE_SUCCESS}
⚡ docker run --rm app cat /BUILD_REV
2017-01-24 05:24:50.360018412 +0000 UTC
#!/bin/sh
echo "Writing '$CI_STRING_TIME' to file /data/BUILD_REV"
echo "$CI_STRING_TIME" > /data/BUILD_REV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment