forked from kreuzwerker/envplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update for single dockerfile-only build
- Loading branch information
1 parent
b42fbf9
commit 1c7d377
Showing
28 changed files
with
82 additions
and
1,799 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build & Publish | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "dev" | ||
tags: | ||
- 'v*.*.*' | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
${{ github.repository_owner }}/envplate | ||
ghcr.io/${{ github.repository_owner }}/envplate | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Login to GHCR | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# syntax=docker/dockerfile:1 | ||
# Build docker-gen from scratch | ||
FROM golang:1.21-alpine AS ep-builder | ||
|
||
ARG VERSION=v1.0.3 | ||
|
||
ADD https://github.com/kreuzwerker/envplate.git#${VERSION} /build | ||
|
||
WORKDIR /build | ||
|
||
RUN go mod download -json | ||
|
||
# Build the docker-gen executable | ||
RUN CGO_ENABLED=0 go build -ldflags '-X main.buildVersion=${VERSION} -extldflags "-static"' -o ep ./bin/ep.go | ||
|
||
FROM scratch | ||
|
||
# Install docker-gen from build stage | ||
COPY --from=ep-builder /build/ep /usr/local/bin/ep | ||
|
||
ENTRYPOINT ["/usr/local/bin/ep"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,5 @@ | ||
# Envplate | ||
# Envplate - amazee.io builder | ||
|
||
[![Release](https://img.shields.io/github/v/release/kreuzwerker/envplate)](https://github.com/kreuzwerker/envplate/releases) | ||
[![Build Status](https://github.com/kreuzwerker/envplate/workflows/build/badge.svg)](https://github.com/kreuzwerker/envplate/actions) | ||
[![Documentation](https://godoc.org/github.com/kreuzwerker/envplate?status.svg)](http://godoc.org/github.com/kreuzwerker/envplate) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/kreuzwerker/envplate)](https://goreportcard.com/report/github.com/kreuzwerker/envplate) | ||
This version of Envplate builds from the upstream releases at https://github.com/kreuzwerker/envplate to configure an up-to-date Dockerfile build for ease of reuse. | ||
|
||
Trivial templating for configuration files using environment keys. References to such keys are declared in arbitrary config files either as: | ||
|
||
1. `${key}` or | ||
* `${key:-default value}` | ||
|
||
Envplate (`ep`) parses arbitrary configuration files (using glob patterns) and replaces all references with values from the environment or with default values (if given). These values replace the keys *inline* (= the files will be changed). | ||
|
||
Failure to resolve the supplied glob pattern(s) to at least one file results in an error. | ||
|
||
Optionally, `ep` can: | ||
|
||
* backup (`-b` flag): create backups of the files it changes, appending a `.bak` extension to backup copies | ||
* dry-run (`-d` flag): output to stdout instead of replacing values inline | ||
* strict (`-s` flag): refuse to fallback to default values | ||
* verbose (`-v` flag): be verbose about it's operations | ||
|
||
`ep` can also `exec()` another command by passing | ||
|
||
* `--` after all arguments to `ep` | ||
* the path to the binary and it's arguments | ||
|
||
Example: `/usr/local/bin/ep -v *.conf -- /usr/sbin/nginx -c /etc/nginx.conf` | ||
|
||
This can be used to use `ep` to parse configs and execute the container process using Dockers `CMD` | ||
|
||
## Escaping | ||
|
||
In case the file you want to modify already uses the pattern envplate is searching for ( e.g. for reading environment variables ) you can escape the sequence by adding a leading backslash `\`. It's also possible to escape a leading backslash by adding an additional backslash. Basically a sequence with an even number of leading backslashes will be parsed, is the number of leading backslashes odd the sequence will be escaped. | ||
|
||
See https://github.com/kreuzwerker/envplate#full-example | ||
|
||
## Why? | ||
|
||
For apps running Docker which rely (fully or partially) on configuration files instead of being purely configured through environment variables. | ||
|
||
You can directly download envplate binaries into your Dockerfile using Github releases like this: | ||
|
||
``` | ||
RUN wget -q https://github.com/kreuzwerker/envplate/releases/download/v1.0.2/envplate_1.0.2_$(uname -s)_$(uname -m).tar.gz -O - | tar xz && mv envplate /usr/local/bin/ep && chmod +x /usr/local/bin/ep | ||
... | ||
CMD [ "/usr/local/bin/ep", "-v", "/etc/nginx/nginx.conf", "--", "/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf" ] | ||
``` | ||
|
||
## Full example | ||
|
||
``` | ||
$ cat /etc/foo.conf | ||
Database=${FOO_DATABASE} | ||
DatabaseSlave=${BAR_DATABASE:-db2.example.com} | ||
Mode=fancy | ||
Escaped1=\${FOO_DATABASE} | ||
NotEscaped1=\\${FOO_DATABASE} | ||
Escaped2=\\\${BAR_DATABASE:-db2.example.com} | ||
NotEscaped2=\\\\${BAR_DATABASE:-db2.example.com} | ||
$ export FOO_DATABASE=db.example.com | ||
$ ep /etc/f*.conf | ||
$ cat /etc/foo.conf | ||
Database=db.example.com | ||
DatabaseSlave=db2.example.com | ||
Mode=fancy | ||
Escaped1=${FOO_DATABASE} | ||
NotEscaped1=\db.example.com | ||
Escaped2=\${BAR_DATABASE:-db2.example.com} | ||
NotEscaped2=\\db2.example.com | ||
``` | ||
The original version is still available at https://github.com/kreuzwerker/envplate |
Oops, something went wrong.