Update readme

This commit is contained in:
Juan Sebastián Montoya 2024-09-10 19:06:16 -05:00
parent b1e63725e8
commit 110541fad2
6 changed files with 47 additions and 26 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
.secrets
.env
volumes

View file

@ -5,11 +5,13 @@
### First Steps
- First, let's create a network to connect all our containers
```bash
docker network create default-network
```
- Then, create a folder named composes in the user's home folder
```bash
mkdir ~/composes
cd ~/composes
@ -17,7 +19,7 @@
- From here, all the next yaml files should be created inside the composes folder
### Setting up secrets
### Setting up secrets
- If we would like to save the composes files in a git repository, we should'nt be writting secrets directly in our yaml files, so we will need to write the secrets somewhere else:
```
@ -48,7 +50,7 @@
image: adminer
restart: always
ports:
- 8080:8080
- 8082:8080
environment:
ADMINER_DEFAULT_SERVER: db-mariadb-1
mariadb:
@ -67,6 +69,7 @@
external: true
name: default-network
```
- As we could see, this yaml file uses two secrets `MYSQL_USER_PASSWORD` and `MYSQL_ROOT_PASSWORD`, both should be defined inside our `.secrets` folder:
```bash
@ -96,7 +99,7 @@
```
- Inside, we could run mariadb operations, an example to add an user should be as follows:
```sql
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
CREATE DATABASE dbname;
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%';
FLUSH PRIVILEGES;
@ -107,6 +110,7 @@
### Setting up yaml
- Create `npm.yml` inside composes with the following content:
```yaml
name: npm
@ -116,12 +120,12 @@
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
image: "jc21/nginx-proxy-manager:latest"
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
- "80:80"
- "81:81"
- "443:443"
# Any port we would like to expose from other services, example 3306 for mariadb/mysql remote access
volumes:
- ./volumes/nginx-proxy-manager/data:/data
@ -140,6 +144,7 @@
external: true
name: default-network
```
- As we could see, this yaml file uses the secret `MYSQL_NPM_PASSWORD`, it be defined inside our `.secrets` folder:
```bash
echo "This is an example, please change" > .secrets/MYSQL_NPM_PASSWORD
@ -148,8 +153,9 @@
### Database setup
- Enter to mariadb and run the following, remember to replace the password with the one in `.secrets/MYSQL_NPM_PASSWORD`:
```sql
CREATE USER 'npm'@'%' IDENTIFIED BY 'password';
CREATE USER 'npm'@'%' IDENTIFIED BY 'password';
CREATE DATABASE npm;
GRANT ALL PRIVILEGES ON npm.* TO 'npm'@'%';
FLUSH PRIVILEGES;
@ -176,6 +182,7 @@ FLUSH PRIVILEGES;
### Setting up yaml
- Create `forgejo.yml` inside composes with the following content:
```yaml
name: forgejo
@ -207,6 +214,8 @@ FLUSH PRIVILEGES;
- FORGEJO__mailer__SMTP_PORT=587
- FORGEJO__mailer__USER=forgejo@example.com
- FORGEJO__mailer__PASSWD__FILE=/run/secrets/MAILER_FORGEJO_PASSWORD
- FORGEJO__service__DISABLE_REGISTRATION=true
- FORGEJO__admin__SEND_NOTIFICATION_EMAIL_ON_NEW_USER=true
secrets:
- MYSQL_FORGEJO_PASSWORD
- MAILER_FORGEJO_PASSWORD
@ -216,8 +225,8 @@ FLUSH PRIVILEGES;
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- '3001:3000'
- '222:22'
- "3001:3000"
- "222:22"
networks:
default:
@ -236,17 +245,18 @@ FLUSH PRIVILEGES;
- You also need to add a stream to port 2222 in npm
- Additionaly, you need to add the custom ssh port to your clients .ssh/config (see [issue](https://stackoverflow.com/questions/5767850/git-on-custom-ssh-port))
### Database setup (Optional, must do it if FORGEJO__database added)
### Database setup (Optional, must do it if FORGEJO\_\_database added)
- Enter to mariadb and run the following, remember to reemplace the password:
```sql
CREATE USER 'forgejo'@'%' IDENTIFIED BY 'password';
CREATE USER 'forgejo'@'%' IDENTIFIED BY 'password';
CREATE DATABASE forgejo;
GRANT ALL PRIVILEGES ON forgejo.* TO 'forgejo'@'%';
FLUSH PRIVILEGES;
```
### Run it
- Run the following commands:
```bash
cd ~/composes
@ -254,6 +264,7 @@ FLUSH PRIVILEGES;
```
### Next steps
- The app could be accesed at http://HOSTNAME:3001
- Before procced with login users we should use https, so npm installation is advised
- The first created user will be the admin
@ -261,7 +272,9 @@ FLUSH PRIVILEGES;
## Nextcloud Container (google drive-like replacement)
### Setting up yaml
- Create `nextcloud.yml`
```yml
name: nextcloud
services:
@ -291,7 +304,9 @@ FLUSH PRIVILEGES;
nextcloud-aio:
name: nextcloud-aio
```
- Update `npm.yml` to include `nextcloud-aio` network:
```yml
# Ommiting lines
services:
@ -299,7 +314,7 @@ FLUSH PRIVILEGES;
# Ommiting lines
networks:
- default
- nextcloud-aio
- nextcloud-aio
networks:
default:
@ -309,7 +324,9 @@ FLUSH PRIVILEGES;
external: true
name: nextcloud-aio
```
### Run it
- Run the following commands:
```bash
cd ~/composes

2
db.yml
View file

@ -11,7 +11,7 @@ services:
image: adminer
restart: always
ports:
- 8080:8080
- 8082:8080
environment:
ADMINER_DEFAULT_SERVER: db-mariadb-1
mariadb:

View file

@ -8,13 +8,13 @@ secrets:
services:
app:
image: codeberg.org/forgejo/forgejo:7
image: codeberg.org/forgejo/forgejo:8.0.3
environment:
- USER_UID=1000
- USER_GID=1000
- FORGEJO__server__DOMAIN=git.jusemon.com
- FORGEJO__server__SSH_DOMAIN=git.jusemon.com
- FORGEJO__server__SSH_PORT=22
- FORGEJO__server__SSH_PORT=2222
- FORGEJO__server__SSH_LISTEN_PORT=2222
- FORGEJO__database__DB_TYPE=mysql
- FORGEJO__database__HOST=db-mariadb-1:3306
@ -28,6 +28,8 @@ services:
- FORGEJO__mailer__SMTP_PORT=587
- FORGEJO__mailer__USER=juansmm@outlook.com
- FORGEJO__mailer__PASSWD__FILE=/run/secrets/MAILER_FORGEJO_PASSWORD
- FORGEJO__service__DISABLE_REGISTRATION=true
- FORGEJO__admin__SEND_NOTIFICATION_EMAIL_ON_NEW_USER=true
secrets:
- MYSQL_FORGEJO_PASSWORD
- MAILER_FORGEJO_PASSWORD
@ -37,10 +39,10 @@ services:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- '3001:3000'
- '2222:22'
- "3001:3000"
- "2222:22"
networks:
default:
name: default-network
external: true
external: true

View file

@ -14,4 +14,4 @@ services:
networks:
default:
name: default-network
external: true
external: true

13
npm.yml
View file

@ -6,16 +6,17 @@ secrets:
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
image: "jc21/nginx-proxy-manager:latest"
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
- '3306:3306'
- "80:80"
- "81:81"
- "443:443"
- "3306:3306"
volumes:
- ./volumes/nginx-proxy-manager/data:/data
- ./volumes/nginx-proxy-manager/letsencrypt:/etc/letsencrypt
- ./volumes/nginx-proxy-manager/snippets:/snippets
environment:
DB_MYSQL_HOST: "db-mariadb-1"
DB_MYSQL_PORT: 3306
@ -26,7 +27,7 @@ services:
- MYSQL_NPM_PASSWORD
networks:
- default
- nextcloud-aio
- nextcloud-aio
networks:
default: