# Enclosed

Enclosed is a minimalistic web application designed for sending private and secure notes. Whether you need to share sensitive information or just want a simple way to send encrypted messages, Enclosed provides a user-friendly interface with strong security features to ensure your data remains confidential.

<ServiceNotice serviceName="pastebox" linkPath="/guides/docker/apps/pastebox" />

### References

<ReferenceLinks references={frontmatter.references} />

---

## Make directory

```sh wrap preserveIndent
mkdir -p {{DOCKER_PATH_VAR}}/enclosed && cd {{DOCKER_PATH_VAR}}/enclosed
```

## Generate key and cert

```sh title="private-key.pem + certificate.pem" wrap preserveIndent
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -keyout private-key.pem -out certificate.pem
```

## Docker run

```sh wrap preserveIndent
docker run -d --name enclosed --restart unless-stopped -p 8787:8787 \
  -v ./data:/app/.data \
  -e SERVER_USE_HTTPS=true \
  -e SERVER_HTTPS_KEY="$(cat ./private-key.pem)" \
  -e SERVER_HTTPS_CERT="$(cat ./certificate.pem)" \
  -e PUBLIC_IS_AUTHENTICATION_REQUIRED=true \
  -e AUTHENTICATION_JWT_SECRET="$(openssl rand -base64 32 | tr -d '/+=')" \
  -e AUTHENTICATION_USERS=email@example.com:\$2a\$10\$hVz60OYDiia7wboP1OBYVeS7ZCBoYPgOS.4BnuwQ/Zh1FSTz9w9py \
  corentinth/enclosed
```

## Docker compose

### compose.yml

```sh
nano compose.yml
```

```yml title="compose.yml"
yaml
```

### docker-compose-up.sh

```sh
nano docker-compose-up.sh
```

```sh title=docker-compose-up.sh wrap preserveIndent
#!/bin/bash

# Clear the contents of the .env file
> .env

# Add the necessary environment variables to .env
echo "SERVER_USE_HTTPS=true" > .env
echo "SERVER_HTTPS_KEY=\"$(cat private-key.pem)\"" >> .env
echo "SERVER_HTTPS_CERT=\"$(cat certificate.pem)\"" >> .env
echo "PUBLIC_IS_AUTHENTICATION_REQUIRED=true" >> .env

# Generate and add the JWT secret to .env
AUTHENTICATION_JWT_SECRET=$(openssl rand -base64 32 | tr -d '/+=')
echo "AUTHENTICATION_JWT_SECRET=\"$AUTHENTICATION_JWT_SECRET\"" >> .env

# Generate and add the hashed user credential to .env
# https://docs.enclosed.cc/self-hosting/users-authentication-key-generator
USER_EMAIL="email@example.com"
USER_PASSWORD='$$2a$$10$$NCkptt9QmnwtijTvg8eWEO0WLCqI.CZvsE/l8seG85upSw8yNSr82'
echo 'AUTHENTICATION_USERS="'"$USER_EMAIL:$USER_PASSWORD"'"' >> .env

# Run Docker Compose
docker compose up -d
```

### Make script executable

```sh
chmod +x docker-compose-up.sh
```

### Start container

```sh
./docker-compose-up.sh
```

## Open web ui

<OpenWebUI port="8787" />
