Fix docker build recipe

This commit is contained in:
wpetit 2022-11-22 15:18:28 -06:00
parent db0a3ac98f
commit 19e15d3fe7
10 changed files with 34 additions and 30 deletions

View File

@ -5,4 +5,5 @@
/bin
/misc/docker/Dockerfile
/.env
/.env.dist
/.env.dist
/tools

3
.gitignore vendored
View File

@ -3,4 +3,5 @@
/vendor
/bin
/node_modules
/.env
/.env
/tools

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v14.16.0

View File

@ -1,4 +1,14 @@
DOCKER_DATE_TAG := $(shell date +%Y%m%d%H%M)
DOCKER_DATE_TAG := $(shell date --utc +%Y.%-m.%-d%-H%-M)
YQ_VERSION ?= v4.30.4
YQ_BINARY ?= yq_linux_amd64
tools: tools/yq/bin/yq
tools/yq/bin/yq:
mkdir -p tools/yq/bin
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY} -O tools/yq/bin/yq &&\
chmod +x tools/yq/bin/yq
build:
CGO_ENABLED=0 go build -v -o bin/fake-smtp ./cmd/fake-smtp
@ -31,7 +41,7 @@ docker-release:
test:
go test -v -race ./...
release: dist
release: dist tools
@./misc/script/release.sh
dist:

View File

@ -1,4 +1,4 @@
FROM golang:1.17 AS build
FROM golang:1.19 AS build
ARG HTTP_PROXY=
ARG HTTPS_PROXY=
@ -14,13 +14,8 @@ COPY . /src
WORKDIR /src
RUN cp -f misc/docker/config-patch.yml misc/release/config-patch.yml
RUN go get github.com/krishicks/yaml-patch/cmd/yaml-patch
RUN npm install \
&& make vendor \
&& echo "---" > ./misc/release/config-patch.yml \
RUN cp -f misc/docker/config-patch.txt misc/release/config-patch.txt \
&& npm install \
&& make ARCH_TARGETS=amd64 release
FROM busybox
@ -31,4 +26,6 @@ WORKDIR /app
RUN mkdir -p /app
EXPOSE 8080 2525
CMD ["bin/fake-smtp", "--config", "config.yml"]

View File

@ -0,0 +1 @@
.smtp.debug = false

View File

@ -1,4 +0,0 @@
---
- op: replace
path: /smtp/debug
value: false

View File

@ -0,0 +1,3 @@
.data.path = "/var/lib/fake-smtp/data.db"
.smtp.address = "127.0.0.1:2525"
.smtp.debug = false

View File

@ -1,10 +0,0 @@
---
- op: replace
path: /data/path
value: /var/lib/fake-smtp/data.db
- op: replace
path: /smtp/address
value: 127.0.0.1:2525
- op: replace
path: /smtp/debug
value: false

View File

@ -73,13 +73,17 @@ function dump_default_conf {
local command=$1
local os=$2
local arch=$3
local tmp_conf=$(mktemp)
local patched_conf=$(mktemp)
go run "$PROJECT_DIR/cmd/$command" -dump-config > "$tmp_conf"
cat "$tmp_conf" | yaml-patch -o misc/release/config-patch.yml > "$patched_conf"
go run "$PROJECT_DIR/cmd/$command" -dump-config > "$patched_conf"
while IFS= read -r yq_cmd; do
echo "patching configuration with '$yq_cmd'..."
tools/yq/bin/yq -i "$yq_cmd" "$patched_conf"
done < misc/release/config-patch.txt
copy "$command" $os $arch "$patched_conf" "config.yml"
rm -f "$tmp_conf" "$patched_conf"
rm -f "$patched_conf"
}
function compress {