Reviewed-on: #1
This commit is contained in:
parent
4ac8229ddc
commit
b223d6c7ee
|
@ -0,0 +1,101 @@
|
||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: test
|
||||||
|
image: rust:latest
|
||||||
|
commands:
|
||||||
|
- mkdir -p ui/build
|
||||||
|
- touch ui/build/index.html
|
||||||
|
- rustup component add clippy
|
||||||
|
- cargo clippy
|
||||||
|
- cargo test --all
|
||||||
|
|
||||||
|
- name: build-ui
|
||||||
|
image: node:18.9.1-slim
|
||||||
|
volumes:
|
||||||
|
- name: temp
|
||||||
|
path: /app
|
||||||
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -y install libssl-dev
|
||||||
|
- cd ui
|
||||||
|
- npm install
|
||||||
|
- npm run build
|
||||||
|
- cp -R ./build /app/ui
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- staging
|
||||||
|
- production
|
||||||
|
|
||||||
|
- name: binary-deploy
|
||||||
|
image: rust:latest
|
||||||
|
depends_on: [ build-ui, test ]
|
||||||
|
volumes:
|
||||||
|
- name: temp
|
||||||
|
path: /app
|
||||||
|
commands:
|
||||||
|
- cp -R /app/ui ./ui/build
|
||||||
|
- cargo build --release
|
||||||
|
- tar cvzf mailspy.tar.gz -C target/release mailspy
|
||||||
|
- wget https://dl.min.io/client/mc/release/linux-amd64/mc
|
||||||
|
- chmod +x mc
|
||||||
|
- ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET
|
||||||
|
- ./mc cp mailspy.tar.gz fivesigma/public/mailspy.tar.gz
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- staging
|
||||||
|
- production
|
||||||
|
|
||||||
|
- name: build-musl
|
||||||
|
image: rust
|
||||||
|
depends_on: [ build-ui, test ]
|
||||||
|
volumes:
|
||||||
|
- name: temp
|
||||||
|
path: /app
|
||||||
|
commands:
|
||||||
|
- cp -R /app/ui ./ui/build
|
||||||
|
- rustup target add x86_64-unknown-linux-musl
|
||||||
|
- apt update && apt install -y musl-tools musl-dev libssl-dev
|
||||||
|
- update-ca-certificates
|
||||||
|
- cargo build --target x86_64-unknown-linux-musl --release
|
||||||
|
- mkdir /app/build
|
||||||
|
- cp target/x86_64-unknown-linux-musl/release/mailspy /app/build/mailspy
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- staging
|
||||||
|
- production
|
||||||
|
|
||||||
|
- name: stage-deploy
|
||||||
|
image: plugins/docker
|
||||||
|
privileged: true
|
||||||
|
depends_on: [ build-musl, test ]
|
||||||
|
volumes:
|
||||||
|
- name: temp
|
||||||
|
path: /app
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: CONTAINER_USER
|
||||||
|
password:
|
||||||
|
from_secret: CONTAINER_PASSWORD
|
||||||
|
registry: git.5sigma.io
|
||||||
|
context: /app/build
|
||||||
|
repo: git.5sigma.io/mailspy/mailspy
|
||||||
|
tags: latest
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- staging
|
||||||
|
- production
|
||||||
|
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: temp
|
||||||
|
temp: {}
|
|
@ -11,7 +11,6 @@ serde = { version = "1.0.145", features = ["derive"] }
|
||||||
serde_json = "1.0.85"
|
serde_json = "1.0.85"
|
||||||
tokio = { version = "1.21.1", features = ["full"] }
|
tokio = { version = "1.21.1", features = ["full"] }
|
||||||
bytes = "1.2.1"
|
bytes = "1.2.1"
|
||||||
lettre = "0.10.1"
|
|
||||||
poem = { version = "1.3.44", features = ["compression", "embed"] }
|
poem = { version = "1.3.44", features = ["compression", "embed"] }
|
||||||
rust-embed = "6.4.1"
|
rust-embed = "6.4.1"
|
||||||
tracing = "0.1.36"
|
tracing = "0.1.36"
|
||||||
|
@ -19,5 +18,7 @@ tracing-subscriber = "0.3.15"
|
||||||
mailparse = "0.13.8"
|
mailparse = "0.13.8"
|
||||||
clap = { version = "3.2.22", features = ["derive"] }
|
clap = { version = "3.2.22", features = ["derive"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
lettre = "0.10.1"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
COPY mailspy /app/mailspy
|
||||||
|
WORKDIR app
|
||||||
|
EXPOSE 7777
|
||||||
|
EXPOSE 7778
|
||||||
|
CMD ./mailspy
|
24
README.org
24
README.org
|
@ -7,10 +7,10 @@ Mailspy is a mock SMTP server for used during development of applications that s
|
||||||
Mailspy is available in binary distribution for 64-bit linux systems.
|
Mailspy is available in binary distribution for 64-bit linux systems.
|
||||||
|
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
curl https://objects.5sigma.io/public/conductor.tar.gz | tar -xz
|
curl https://objects.5sigma.io/public/mailspy.tar.gz | tar -xz
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Usage
|
* Binary usage
|
||||||
|
|
||||||
Execute the mailspy binary:
|
Execute the mailspy binary:
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@ Execute the mailspy binary:
|
||||||
|
|
||||||
Then set your application to use the following smtp settings:
|
Then set your application to use the following smtp settings:
|
||||||
|
|
||||||
*SMTP Server*: localhost
|
*- SMTP Server*: localhost
|
||||||
*Port*: 7778
|
*- Port*: 7778
|
||||||
*Username*: Any value
|
*- Username*: Any value
|
||||||
*Password*: Any value
|
*- Password*: Any value
|
||||||
*TLS*: None/Unsecured
|
*- TLS*: None/Unsecured
|
||||||
*Authorization Type*: Basic Auth
|
*- Authorization Type*: Basic Auth
|
||||||
|
|
||||||
View emails in the web interface served at:
|
View emails in the web interface served at:
|
||||||
|
|
||||||
|
@ -37,6 +37,14 @@ http://localhost:7777
|
||||||
- The HTTP port for the web interface can be configured with -h <port>
|
- The HTTP port for the web interface can be configured with -h <port>
|
||||||
|
|
||||||
|
|
||||||
|
* Docker
|
||||||
|
|
||||||
|
Mailspy is avialable as a Docker image. To run it as a temporary container use:
|
||||||
|
|
||||||
|
#+begin_src sh
|
||||||
|
docker run --rm -p 7777:7777 -p 7778:7778 git.5sigma.io/mailspy/mailspy:latest
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Development
|
* Development
|
||||||
|
|
||||||
The core application Rust application is located in /src folder. This contains both the SMTP and HTTP servers. The web interface is located in /ui and is a Svelte application.
|
The core application Rust application is located in /src folder. This contains both the SMTP and HTTP servers. The web interface is located in /ui and is a Svelte application.
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub async fn server(mailbox: Mailbox, port: u16) -> anyhow::Result<()> {
|
||||||
.at("/", EmbeddedFileEndpoint::<Files>::new("index.html"))
|
.at("/", EmbeddedFileEndpoint::<Files>::new("index.html"))
|
||||||
.nest("/", EmbeddedFilesEndpoint::<Files>::new())
|
.nest("/", EmbeddedFilesEndpoint::<Files>::new())
|
||||||
.with(AddData::new(mailbox));
|
.with(AddData::new(mailbox));
|
||||||
if let Err(e) = Server::new(TcpListener::bind(format!("localhost:{}", port)))
|
if let Err(e) = Server::new(TcpListener::bind(format!("0.0.0.0:{}", port)))
|
||||||
.run(app)
|
.run(app)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn server(mailbox: Mailbox, port: u16) -> anyhow::Result<()> {
|
pub async fn server(mailbox: Mailbox, port: u16) -> anyhow::Result<()> {
|
||||||
let addr = format!("127.0.0.1:{}", port);
|
let addr = format!("0.0.0.0:{}", port);
|
||||||
let listener = TcpListener::bind(&addr).await?;
|
let listener = TcpListener::bind(&addr).await?;
|
||||||
tracing::info!(port =? port, "SMTP Server running");
|
tracing::info!(port =? port, "SMTP Server running");
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
|
Loading…
Reference in New Issue