8 Commits

16 changed files with 112 additions and 34 deletions

View File

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

3
.gitignore vendored
View File

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

1
.nvmrc
View File

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

View File

@ -1,14 +1,4 @@
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
DOCKER_DATE_TAG := $(shell date +%Y%m%d%H%M)
build:
CGO_ENABLED=0 go build -v -o bin/fake-smtp ./cmd/fake-smtp
@ -41,7 +31,7 @@ docker-release:
test:
go test -v -race ./...
release: dist tools
release: dist
@./misc/script/release.sh
dist:

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

14
debian/control vendored Normal file
View File

@ -0,0 +1,14 @@
Source: fake-smtp
Section: unknown
Priority: optional
Maintainer: William Petit <wpetit@cadoles.com>
Build-Depends: debhelper (>= 8.0.0), wget, ca-certificates, tar, curl
Standards-Version: 3.9.4
Homepage: http://forge.cadoles.com/wpetit/fake-smtp
Vcs-Git: http://forge.cadoles.com/wpetit/fake-smtp.git
Vcs-Browser: http://forge.cadoles.com/wpetit/fake-smtp
Package: fake-smtp
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Serveur SMTP factice pour le développement avec interface web

1
debian/fake-smtp.dirs vendored Normal file
View File

@ -0,0 +1 @@
var/lib/fake-smtp

11
debian/fake-smtp.service vendored Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Serveur SMTP factice pour le développement avec interface web
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/fake-smtp -workdir /usr/share/fake-smtp -config /etc/fake-smtp/config.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target

54
debian/rules vendored Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
GO_VERSION := 1.14.2
OS := linux
ARCH := amd64
GOPATH=$(HOME)/go
ifeq (, $(shell which go 2>/dev/null))
override_dh_auto_build: install-go
endif
ifeq (, $(shell which node 2>/dev/null))
override_dh_auto_build: install-nodejs
endif
%:
dh $@ --with systemd
override_dh_auto_build: $(GOPATH)
GOPATH=$(GOPATH) PATH="$(PATH):/usr/local/go/bin:$(GOPATH)/bin" make tooling
npm install
GOPATH=$(GOPATH) PATH="$(PATH):/usr/local/go/bin:$(GOPATH)/bin" go mod vendor
GOPATH=$(GOPATH) PATH="$(PATH):/usr/local/go/bin:$(GOPATH)/bin" ARCH_TARGETS=$(ARCH) make release
$(GOPATH):
mkdir -p $(GOPATH)
install-go:
wget https://dl.google.com/go/go$(GO_VERSION).$(OS)-$(ARCH).tar.gz
tar -C /usr/local -xzf go$(GO_VERSION).$(OS)-$(ARCH).tar.gz
install-nodejs:
curl -sL https://deb.nodesource.com/setup_13.x | bash -
apt-get install -y nodejs
override_dh_auto_install:
mkdir -p debian/fake-smtp/usr/share/fake-smtp
mkdir -p debian/fake-smtp/etc/fake-smtp
mkdir -p debian/fake-smtp/usr/bin
cp -r release/fake-smtp-$(OS)-$(ARCH)/* debian/fake-smtp/usr/share/fake-smtp/
mv debian/fake-smtp/usr/share/fake-smtp/bin/fake-smtp debian/fake-smtp/usr/bin/fake-smtp
mv debian/fake-smtp/usr/share/fake-smtp/config.yml debian/fake-smtp/etc/fake-smtp/config.yml
install -d debian/fake-smtp
override_dh_strip:
override_dh_auto_test:

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,10 @@
---
- 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,17 +73,13 @@ 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 > "$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
go run "$PROJECT_DIR/cmd/$command" -dump-config > "$tmp_conf"
cat "$tmp_conf" | yaml-patch -o misc/release/config-patch.yml > "$patched_conf"
copy "$command" $os $arch "$patched_conf" "config.yml"
rm -f "$patched_conf"
rm -f "$tmp_conf" "$patched_conf"
}
function compress {