Skip to content

Commit

Permalink
Build env2yaml as a different stage
Browse files Browse the repository at this point in the history
  • Loading branch information
roaksoax committed May 2, 2024
1 parent 213c5d0 commit 4522f59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ build-from-local-ubi8-artifacts: dockerfile env2yaml
(docker kill $(HTTPD); false);
-docker kill $(HTTPD)

build-from-local-wolfi-artifacts: dockerfile env2yaml
build-from-local-wolfi-artifacts: dockerfile
docker run --rm -d --name=$(HTTPD) \
-p 8000:8000 --expose=8000 -v $(ARTIFACTS_DIR):/mnt \
python:3 bash -c 'cd /mnt && python3 -m http.server'
Expand Down
18 changes: 17 additions & 1 deletion docker/templates/Dockerfile.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# This Dockerfile was generated from templates/Dockerfile.erb
<% if image_flavor == 'wolfi' -%>
FROM docker.elastic.co/wolfi/go:1-dev as builder-env2yaml

COPY env2yaml/env2yaml.go /tmp/go/src/env2yaml/env2yaml.go
COPY env2yaml/go.mod /tmp/go/src/env2yaml/go.mod
COPY env2yaml/go.sum /tmp/go/src/env2yaml/go.sum

WORKDIR /tmp/go/src/env2yaml

RUN go build
<% end -%>
<% if image_flavor == 'ironbank' -%>
<%# Start image_flavor 'ironbank' %>
ARG BASE_REGISTRY=registry1.dso.mil
Expand Down Expand Up @@ -78,7 +90,7 @@ RUN dnf -y upgrade && \
# Minimal distributions do not ship with en language packs.
<% locale = 'C.UTF-8' -%>
<% elsif image_flavor == 'wolfi' %>
<% base_image = 'cgr.dev/chainguard/wolfi-base' -%>
<% base_image = 'docker.elastic.co/wolfi/chainguard-base' -%>
<% package_manager = 'apk' -%>
<% arch_command = 'uname -m' -%>
# Minimal distributions do not ship with en language packs.
Expand Down Expand Up @@ -175,6 +187,9 @@ RUN chown --recursive logstash:root config/ pipeline/
# Ensure Logstash gets the correct locale by default.
ENV LANG=<%= locale %> LC_ALL=<%= locale %>
<% if image_flavor == 'wolfi' -%>
COPY --from=builder-env2yaml /tmp/go/src/env2yaml/env2yaml /usr/local/bin/env2yaml
<% else -%>
# Copy over the appropriate env2yaml artifact
RUN env2yamlarch="$(<%= arch_command %>)"; \
case "${env2yamlarch}" in \
Expand All @@ -189,6 +204,7 @@ RUN env2yamlarch="$(<%= arch_command %>)"; \
mkdir -p /usr/local/bin; \
cp env2yaml/env2yaml-${env2yamlarch} /usr/local/bin/env2yaml; \
rm -rf env2yaml
<% end -%>
# Place the startup wrapper script.
COPY bin/docker-entrypoint /usr/local/bin/

Expand Down

0 comments on commit 4522f59

Please sign in to comment.