1
0

Update README.

This commit is contained in:
Kevin Matsubara 2025-03-17 19:59:11 +01:00
parent bda9f5dc59
commit 48a588a3fb

131
README.md
View File

@ -2,36 +2,135 @@
## Local ## Local
Docker commands to create the local containers.
`docker build -t pa4kev/portfolio-reactjs-full:latest -f Dockerfile .` `docker build -t pa4kev/portfolio-reactjs-full:latest -f Dockerfile .`
`docker push pa4kev/portfolio-reactjs-full:latest` `docker push pa4kev/portfolio-reactjs-full:latest`
## Server (Enaga) ## Server (Enaga)
### GNU/Linux
* Create user, set password, set shell and add to sudo group.
`useradd -m <user>`
`passwd <user>`
`chsh -s /bin/bash <user>`
`adduser <user> sudo`
* Then create an `.ssh` folder for `<user>` in the home folder and create a file called `authorized_keys` as the public key on the local machine. Then copy the contents of the public key to the new file.
* Update the hostname.
`hostnamectl set-hostname enaga`
`vim /etc/hosts`
* [Install docker](https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script)
* Allow docker to be run without sudo commands. (Log out and back in later)
`sudo gpasswd -a $USER docker`
* Install Nginx
`sudo apt-get update`
`sudo apt-get install nginx`
* Copy the nginx configuration file with `scp` to the server.
* Move the nginx configuration file to: `sites-available`.
`sudo mv matsubara.nl /etc/nginx/sites-available/matsubara.nl`
* Create a symbolic link to: `sites-enabled`.
`sudo ln -s /etc/nginx/sites-available/matsubara.nl matsubara.nl`
* Now the certificates need to be created, these are already used by the configuration file, so you cannot restart nginx at this moment. Run the related `docker` commands first to create the certificates. Make sure that the DNS points to the correct IP address before creating the certificates.
### Docker
To no longer require `sudo` for docker, use:
`sudo groupadd docker`
`sudo gpasswd -a $USER docker`
### Docker network
You can create a custom [network](https://docs.docker.com/reference/cli/docker/network/). Note that docker already has some default network called **bridge** that you can use. But note that DNS [host name resolving](https://forums.docker.com/t/cant-resolve-docker-container-names-have-to-use-docker-ip-address/138753) only works on custom networks.
* To list all networks:
`docker network ls`
* Create a custom network:
`docker network create -d bridge uguisu`
* To add an existing container to a network:
`docker network connect uguisu container-name`
* Or specify in the run command:
`docker run --network=uguisu`
* Inspect a network with:
`docker inspect uguisu`
* Inspect which networks are connected to a container:
`docker inspect container-name | grep "Network"`
### Postgres database
* Create a [postgres database container](https://hub.docker.com/_/postgres).
`docker run -d --name database -e POSTGRES_USER=gitea -e POSTGRES_PASSWORD=password -e POSTGRES_DB=gitea -v ./volume-postgres:/var/lib/postgresql/data postgres:17.4-bookworm`
* Import the database SQL export file. [Copy](https://docs.docker.com/reference/cli/docker/container/cp/) the backup file to the container and then run **psql** to import it.
`docker cp backup.sql database:/backup.sql`
`docker exec -it database bash`
`psql --username=gitea gitea < backup.sql`
### Website containers
`docker pull pa4kev/portfolio-reactjs-full` `docker pull pa4kev/portfolio-reactjs-full`
if required, run certbot to set the certificates. if required, run certbot to set the certificates.
* First stop Nginx, as it is using port 80 * First stop Nginx, as it is using port 80
``sudo systemctl stop nginx.service`` ``sudo systemctl stop nginx.service``
* Run this container, I doubt that i am understanding how it works properly though. * Run this container, I doubt that i am understanding how it works properly though.
`docker run -it --rm -p 80:80 --name certbot -v "/etc/letsencrypt:/etc/letsencrypt" -v "/var/lib/letsencrypt:/var/lib/letsencrypt" certbot/certbot certonly --standalone --break-my-certs -d matsubara.nl -d www.matsubara.nl -d pa4kev.nl -d www.pa4kev.nl -d michelaben.nl -d www.michelaben.nl -d gitea.matsubara.nl` `docker run -it --rm -p 80:80 --name certbot -v "/etc/letsencrypt:/etc/letsencrypt" -v "/var/lib/letsencrypt:/var/lib/letsencrypt" certbot/certbot certonly --standalone --break-my-certs -d matsubara.nl -d www.matsubara.nl -d pa4kev.nl -d www.pa4kev.nl -d michelaben.nl -d www.michelaben.nl -d gitea.matsubara.nl`
`docker run -it --rm --name certbot --net webproxy -v $(pwd)/letsencrypt:/etc/letsencrypt -v $(pwd)/letsencrypt-lib:/var/lib/letsencrypt certbot/certbot certonly --standalone --preferred-challenges http -d matsubara.nl -d www.matsubara.nl -d pa4kev.nl -d www.pa4kev.nl -d michelaben.nl -d www.michelaben.nl -d gitea.matsubara.nl`
* Start Nginx again. * Start Nginx again.
`sudo systemctl start nginx.service` `sudo systemctl start nginx.service`
* Run the portfolio container. * Run the portfolio container.
`docker run -t -d --name react -p 8080:80 -v /var/www/html:/var/www/html pa4kev/portfolio-reactjs-full` `docker run -t -d --name react -p 8080:80 -v /var/www/html:/var/www/html pa4kev/portfolio-reactjs-full`
* `-t` foreground mode * `-t` foreground mode
* `-d` detached mode * `-d` detached mode
* Run the Gitea container.
`docker run -d --name gitea -p 3000:3000 -p 222:22 -v ./gitea:/data -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro gitea/gitea:1.22.6`
`docker run -it --rm --name certbot --net webproxy -v $(pwd)/letsencrypt:/etc/letsencrypt -v $(pwd)/letsencrypt-lib:/var/lib/letsencrypt certbot/certbot certonly --standalone --preferred-challenges http -d matsubara.nl -d www.matsubara.nl -d pa4kev.nl -d www.pa4kev.nl -d michelaben.nl -d www.michelaben.nl -d gitea.matsubara.nl`
## Nginx ## Nginx
`sudo vim /etc/nginx/sites-available/matsubara.nl` `sudo vim /etc/nginx/sites-available/matsubara.nl`
@ -42,17 +141,22 @@ if required, run certbot to set the certificates.
## Gitea ## Gitea
`docker run -d --name gitea -p 3000:3000 -p 222:22 -v ./gitea:/data -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro gitea/gitea:1.22.6` * Run the [Gitea container](https://hub.docker.com/r/gitea/gitea).
`docker run -d --name gitea --network=uguisu -p 3000:3000 -p 222:22 -v ./gitea:/data -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro gitea/gitea:1.23.5`
* Adjust settings for gitea. * Adjust settings for gitea.
`docker exec -it gitea bash` `docker exec -it gitea bash`
`vi ./data/gitea/conf/app.ini` `vi ./data/gitea/conf/app.ini`
* Applied this setting. See also: [Gitea config cheatsheet](https://docs.gitea.com/next/administration/config-cheat-sheet) * Applied this setting. See also: [Gitea config cheatsheet](https://docs.gitea.com/next/administration/config-cheat-sheet)
`DISABLE_REGISTRATION = true` `DISABLE_REGISTRATION = true`
* Then restart the container. * Then restart the container.
`docker container restart gitea` `docker container restart gitea`
## React ## React
@ -87,7 +191,7 @@ List outdated packages: `npm outdated`
Update all dependancies: `npm update` Update all dependancies: `npm update`
--- ## Elm
`elm init` `elm init`
@ -114,17 +218,6 @@ You can now run for development:
`elm make src/Main.elm --output=index.js` `elm make src/Main.elm --output=index.js`
---
## Docker
To no longer require `sudo` for docker, use:
* `sudo groupadd docker`
* `sudo gpasswd -a $USER docker`
---
## Documentation ## Documentation
[Create React App](https://github.com/facebook/create-react-app) [Create React App](https://github.com/facebook/create-react-app)
@ -143,6 +236,8 @@ To no longer require `sudo` for docker, use:
[Docker hub - Nginx](https://hub.docker.com/_/nginx) [Docker hub - Nginx](https://hub.docker.com/_/nginx)
---
### Code Splitting ### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)