Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Dockerfile to build source and make build-args optional #110

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,46 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# About this Triage Party Dockerfile:
############################################################################
# About this Dockerfile
#
# This Dockerfile is optimized for local development or basic deployments,
# as it bakes your config file and optional local cached GitHub data.
# This Dockerfile is optimized for local development or deployments which
# require the configuration file to be baked into the resulting image.
#
# If you would rather pass configuration in via other means, such as a
# ConfigMap, use the "triageparty/triage-party" image, or build the
# equivalent image yourself using "base.Dockerfile"
#
# Party on!
# ConfigMap or environment variable, use the "triageparty/triage-party"
# image published on Docker Hub, or build the equivalent
# using "base.Dockerfile"

# Stage 1: Build Triage Party (identical to base.Dockerfile)
FROM golang AS builder
WORKDIR /app
ENV SRC_DIR=/src/tparty
ENV GO111MODULE=on
RUN mkdir -p ${SRC_DIR}/cmd ${SRC_DIR}/third_party ${SRC_DIR}/pkg ${SRC_DIR}/site /app/third_party /app/site
COPY go.* $SRC_DIR/
COPY cmd ${SRC_DIR}/cmd/
COPY pkg ${SRC_DIR}/pkg/
WORKDIR $SRC_DIR
RUN go mod download
RUN go build cmd/server/main.go

# Stage 1: Copy local persistent cache into temp container containing "mv"
# Stage 2: Copy local persistent cache into temp container containing "mv"
FROM alpine AS temp
# CFG is the path to your Triage Party configuration
ARG CFG
ARG CFG=config/config.yaml
COPY pcache /pc
RUN echo "failure is OK with this next step (cache population)"
RUN echo "Pre-populating cache if found (failure is perfectly OK)"
RUN mv /pc/$(basename $CFG).pc /config.yaml.pc || touch /config.yaml.pc


# Stage 2: Copy persistent cache & configuration into application container
FROM triageparty/triage-party
ARG CFG
# Stage 3: Build the configured application container
FROM gcr.io/distroless/base AS triage-party
ARG CFG=config/config.yaml
COPY --from=builder /src/tparty/main /app/
COPY --from=temp /config.yaml.pc /app/pcache/config.yaml.pc
COPY site /app/site/
COPY third_party /app/third_party/
COPY $CFG /app/config/config.yaml


# Useful environment variables:
#
# * GITHUB_TOKEN: Sets GitHub API token
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ Run:
```shell
go run cmd/server/main.go \
--github-token-file=$HOME/.github-token \
--config examples/generic-kubernetes.yaml \
--config config/examples/kubernetes.yaml \
--repos kubernetes/sig-release
```

If you do not have [Go](https://golang.org/) installed, you can run Triage Party using Docker:

```shell
docker build --tag=tp --build-arg CFG=examples/generic-project.yaml .
docker build --tag=tp .
docker run -e GITHUB_TOKEN=$(cat $HOME/.github-token) -p 8080:8080 tp
```

Expand Down