Skip to content

Commit

Permalink
Merge pull request #74 from jsuereth/create-docker-image
Browse files Browse the repository at this point in the history
Add docker image and publishing rules for weaver
  • Loading branch information
jsuereth authored Apr 1, 2024
2 parents 7273f92 + 1696a65 commit 154e52f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Weaver Docker Generator
on:
push:
tags: [ '**' ]
branches:
- main
pull_request:
branches:
- main
paths:
- .github/workflows/publish-docker.yml
- 'src/**'
- 'creates/**'

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . -t weaver && docker run --rm weaver --help

build-and-publish-docker:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . -t weaver
- name: Push the Docker image
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
function tag_and_push {
docker tag weaver "otel/weaver:${1}" && docker push "otel/weaver:${1}"
}
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
tag_and_push "latest"
elif [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
TAG="${GITHUB_REF#"refs/tags/v"}"
tag_and_push "${TAG}"
else
tag_and_push "${GITHUB_REF#"refs/tags/"}"
fi
- name: Push the Dev Docker image
if: startsWith(github.ref, 'refs/heads/feature/')
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
function tag_and_push {
docker tag weaver "otel/weaver:${1}" && docker push "otel/weaver:${1}"
}
TAG="${GITHUB_REF#"refs/heads/"}"
TAG="${TAG/"/"/"-"}"
tag_and_push "${TAG}"
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# The build image
FROM rust:1.76.0-alpine3.18 as weaver-build
RUN apk add musl-dev
WORKDIR /build
# list out directories to avoid pulling local cargo `target/`
COPY Cargo.toml /build/Cargo.toml
COPY Cargo.lock /build/Cargo.lock
COPY crates /build/crates
COPY data /build/data
COPY src /build/src
COPY templates /build/templates
COPY tests build/tests
RUN cargo build --release

# The runtime image
FROM alpine:3.18.3
LABEL maintainer="The OpenTelemetry Authors"
WORKDIR /weaver
COPY --from=weaver-build /build/target/release/weaver /weaver/weaver
ENTRYPOINT ["/weaver/weaver"]

0 comments on commit 154e52f

Please sign in to comment.