Nsustain / nsustain.com

🌳 Source code for Nsustain.com
https://nsustain.com
MIT License
3 stars 0 forks source link
docker-compose environment kubernetes sustainability

logo


List of contributors page MIT License





Source code for Nsustain.com

This repository shows you how to run it and how it works. Read the whole documentation if you'd like to get an overall understanding of how Nsustain works. If you just want to spin up a development server as soon as possible, just read the first section ⚡



Getting Started

1. How to spin up a development server
2. How to set up a production server



1. How to spin up a developmental server

Install

sudo dnf install -y git
git clone https://github.com/Nsustain/nsustain.com.git

# Install Docker Compose.
# If your OS isn't Fedora, follow Docker's documentation:
#   https://docs.docker.com/compose/install/
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo \
  https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin


Run

cd nsustain.com/src/docker
docker compose build
docker compose up

We know that the server is ready when it prints out:

[INFO] Starting php-fpm...
[INFO] Starting nginx

That's it! 🥳 Open http://127.0.0.1

Development server screenshot


[!IMPORTANT]
The default admin ID is nim3594, and the password is 369FQUv4eS. These are baked inside flarum.Dockerfile. and mariadb.Dockerfile. For production, ensure that these default passwords are changed.


How to stop

# Press <Ctrl + c> to exit from your Docker Compose process

# Then, shut down docker compose
docker compose down


How to restart

cd nsustain.com/src/docker
docker compose up -d


Workflows we use


# How to start a shell inside nsustain/flarum container
docker compose exec -it flarum sh

# How to start a shell inside nsustain/mariadb container
docker compose exec -it maraidb sh

# How to check all environment variables injected
env

# How to look inside the database
docker compose exec -it flarum sh
mariadb -h $DB_HOST -u $DB_USER -p$DB_PASS

# How to extract a file from container
docker ps  # Suppose <CONTAINER ID> is 1b332ed2d10e
docker cp 1b332:/path/to/file ./

# How to reset all data and restart with fresh volumes
docker compose down
alias dockervrm="docker volume ls -q | xargs docker volume rm"
dockervrm
docker compose up -d

# How to renew letsencrypt certificate
docker compose exec -it flarum sh
certbot renew



2. How to set up a production server

First, we have to override the default environmental variables. Otherwise, your website's admin credentials will be using ID: nim3594 and PW: 369FQUv4eS because these are baked inside as default env variables.


Override the default env variables at .envflarum and .envmariadb

cd nsustain.com/src/docker
cp exampleenvflarum .envflarum
vim .envflarum
#<Edit the values of the env variables>

cp exampleenvmariadb .envmariadb
vim .envmariadb
#<Edit the values of the env variables>


Enable .envflarum and .envmariadb

vim compose.yaml
    # Uncomment to override env variables for flarum
    #env_file:
    #  - .envflarum

    # It should look like this now:
    env_file:
      - .envflarum

    # Uncomment to override env variables for mariadb
    #env_file:
    #  - .envmariadb

    # It should look like this now:
    env_file:
      - .envmariadb

Any environment variables defined in the .envflarum and .envmariadb files will be used within the server. It is important to set secure passwords for the admin password, MariaDB root password, and database password. We recommend using.


Run

docker compose up -d