Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
FROM ocaml/opam:debian-12-ocaml-4.14
FROM ocaml/opam:debian-12-ocaml-5.3
COPY --from=hadolint/hadolint:latest-alpine /bin/hadolint /bin/hadolint

USER root

# copy hadolint
COPY --from=hadolint/hadolint:latest-alpine /bin/hadolint /bin/hadolint

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND noninteractive
ENV SIHL_ENV development
ENV DEBIAN_FRONTEND=noninteractive

# install packages
# hadolint ignore=DL3008
RUN apt-get update -q && apt-get install -yqq --no-install-recommends \
# development dependencies
inotify-tools \
zsh \
m4 \
wget \
#
# build dependencies (would also be installed by opam depext)
gcc \
jq \
libev-dev \
libgmp-dev \
libssl-dev \
pkg-config \
wget \
zsh \
#
# cleanup installations
&& apt-get autoremove -y \
Expand All @@ -33,9 +24,9 @@ RUN apt-get update -q && apt-get install -yqq --no-install-recommends \
# add timezone
RUN ln -fs /usr/share/zoneinfo/Europe/Zurich /etc/localtime

# WTF: https://github.com/mirage/ocaml-cohttp/issues/675
RUN bash -c 'echo "http 80/tcp www # WorldWideWeb HTTP" >> /etc/services' \
&& bash -c 'echo "https 443/tcp www # WorldWideWeb HTTPS" >> /etc/services'
# link opam version
# hadolint ignore=DL3059
RUN ln -fs /usr/bin/opam-2.2 /usr/bin/opam

USER opam

Expand Down
7 changes: 1 addition & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3 or the
// devcontainer docu https://code.visualstudio.com/docs/remote/containers#_devcontainerjson-reference
{
"name": "letters",
"dockerComposeFile": "./docker-compose.yml",
"service": "dev",
"workspaceFolder": "/workspace",
"privileged": true,
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh",
// Supported customizations: https://containers.dev/supporting
"postCreateCommand": ".devcontainer/postCreate.sh",
"customizations": {
"vscode": {
"settings": {
Expand All @@ -27,7 +23,6 @@
"kind": "global"
}
},
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"donjayamanne.githistory",
"eamodio.gitlens",
Expand Down
15 changes: 10 additions & 5 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ services:
- ..:/workspace:cached
- opam:/home/opam/.opam:cached
- build:/workspace/_build:cached
- ${HOME}${USERPROFILE}/.ssh:/home/opam/.ssh
- ${HOME}${USERPROFILE}/.gitconfig:/home/opam/.gitconfig
- ${HOME}${USERPROFILE}/.gitignore_global:/home/opam/.gitignore_global
environment:
- OPAMSOLVERTIMEOUT=180
- VERSION=dev
OPAMSOLVERTIMEOUT: 180
VERSION: dev
command: sleep infinity

mailtrap:
image: mailhog/mailhog
container_name: mailtrap-letters
hostname: mailtrap-letters
ports:
- "1025:1025" # SMTP server
- "8025:8025" # Web UI

volumes:
opam:
build:
11 changes: 0 additions & 11 deletions .devcontainer/postCreate.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@
# immediately when a command fails and print each command
set -ex

# When possible to create cached docker volume,
sudo chown -R opam: _build

opam init -a --shell=zsh

# get newest opam packages
opam remote remove --all default
opam remote add default https://opam.ocaml.org

opam pin add -yn letters .
opam depext -y letters

# install opam packages used for vscode ocaml platform package
# e.g. when developing with emax, add also: utop merlin ocamlformat
opam install -y ocaml-lsp-server
make deps
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.merlin
*_account.json
.vscode
.env
.DS_Store
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: deps
deps: ## Install development dependencies
opam install --deps-only --with-test --with-doc -y .
opam install --working-dir --with-dev-setup --with-test --with-doc --update-invariant -y .
eval $(opam env)

.PHONY: create_switch
Expand Down
3 changes: 2 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
;; Documentation dependencies
(odoc :with-doc)
;; Dev dependencies
(ocamlformat :dev)))
(ocamlformat :with-dev-setup)
(ocaml-lsp-server :with-dev-setup)))

(implicit_transitive_deps false)
3 changes: 2 additions & 1 deletion letters.opam
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ depends: [
"alcotest-lwt" {>= "1.1.0" & with-test}
"yojson" {>= "1.7.0" & with-test}
"odoc" {with-doc}
"ocamlformat" {dev}
"ocamlformat" {with-dev-setup}
"ocaml-lsp-server" {with-dev-setup}
]
build: [
["dune" "subst"] {dev}
Expand Down
97 changes: 0 additions & 97 deletions letters.opam.locked

This file was deleted.

1 change: 1 addition & 0 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
sendmail.starttls
tls
tls-lwt
unix
x509))

(env
Expand Down
9 changes: 7 additions & 2 deletions lib/sendmail_handler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ let run_with_starttls
recipients
mail_stream
in
Lwt_scheduler.prj fiber)
Lwt.finalize
(fun () -> Lwt_scheduler.prj fiber)
(fun () -> Lwt_io.close ic >>= fun () -> Lwt_io.close oc))
;;

let run ~hostname ?port ~domain ?authentication ~tls_authenticator ~from ~recipients ~mail
=
let open Lwt.Infix in
let ( let* ) = Lwt_result.bind in
let port =
match port with
Expand Down Expand Up @@ -129,5 +132,7 @@ let run ~hostname ?port ~domain ?authentication ~tls_authenticator ~from ~recipi
recipients
mail_stream
in
Lwt_scheduler.prj fiber
Lwt.finalize
(fun () -> Lwt_scheduler.prj fiber)
(fun () -> Lwt_io.close ic >>= fun () -> Lwt_io.close oc)
;;