Running-WikiJS: Difference between revisions

From Irregularpedia
Jump to navigation Jump to search
Initial
 
syntax
Tag: 2017 source edit
 
Line 1: Line 1:
https://docs.requarks.io/install/docker#using-docker-compose
= Configure Wiki.js with Docker Compose =


Using docker compose is a little easier for updating making sure it is all done safely. Shooters preference of course. ## Configure WIKIJS Create this <code>docker-compose.yml</code> file preferably in a user home directory for wikijs See [[Linux%20Server%20Initial%20Setup.md|Linux Server Initial Setup]]
Using Docker Compose simplifies the process of updating Wiki.js while ensuring safe practices. This is a matter of personal preference, but it's a highly recommended approach for managing Dockerized services.


<pre class="yml">version: &quot;3&quot;
== Configure Wiki.js ==
 
Create the following <code>docker-compose.yml</code> file in a user home directory for Wiki.js. Refer to the [[Linux Server Initial Setup]] guide for preliminary server setup.
 
<pre class="yml">
version: "3"
services:
services:


Line 13: Line 18:
       POSTGRES_USER: wikijs
       POSTGRES_USER: wikijs
     logging:
     logging:
       driver: &quot;none&quot;
       driver: "none"
     restart: unless-stopped
     restart: unless-stopped
     volumes:
     volumes:
Line 31: Line 36:
     restart: unless-stopped
     restart: unless-stopped
     ports:
     ports:
       - &quot;XZY:3000&quot;
       - "XZY:3000"


volumes:
volumes:
   db-data:</pre>
   db-data:
Update the port as needed where it says xyz. <code>&quot;80:3000&quot;</code> is the typical port 80 but if you are serving this on other ports with [[self-host-cloudflare-tunnels.md|self-host-cloudflare-tunnels]] then you can set this to anything you want.
</pre>
 
* Update the port where it says `XZY` (e.g., `80:3000` for typical use). If using [[self-host-cloudflare-tunnels]], adjust to your desired port.
* Replace the placeholder passwords (`super_secret_here`) with secure values.
 
== Run Wiki.js ==
 
To run Wiki.js, execute the following command:
 
<pre>
docker compose up -d
</pre>
 
== Update Wiki.js ==
 
To safely update Wiki.js, use:
 
<pre>
docker-compose pull && docker-compose up -d
</pre>
 
This command will pull the latest images specified in your `docker-compose.yml` file and restart the containers in detached mode.
 
== Backup Wiki.js ==


Update the passwords: super_secret_here
Backup your data before updating or making significant changes. Use the following command to create a database dump:


<span id="run-wikijs"></span>
<pre>
== Run WIKIJS ==
docker exec -t db pg_dumpall -c -U wikijs > dump_$(date +"%d-%m-%Y_%H-%M-%S").sql
</pre>


<syntaxhighlight lang="shell">docker compose up -d</syntaxhighlight>
* Replace `db` with the name of your database container if it's different.
<span id="update-wikijs"></span>
== Update WIKIJS ==


<syntaxhighlight lang="shell">docker-compose pull && docker-compose up -d</syntaxhighlight>
Verify the logs of your Wiki.js container after the update to ensure it’s running correctly:
This command will first pull any updates for the Docker images specified in your <code>docker-compose.yml</code> file, and then restart your Docker containers with the new images in detached mode.


<span id="backup-wikijs"></span>
<pre>
== Backup WIKIJS ==
docker logs wiki
</pre>


Remember to always backup your data before updating. You can use commands like:
To restore the backup if needed:


<syntaxhighlight lang="shell">docker exec -t your-db-container pg_dumpall -c -U wikijs > dump_<code>date +%d-%m-%Y"_"%H_%M_%S</code>.sql</syntaxhighlight>
<pre>
This command will create a dump of your database. Replace <code>your-db-container</code> with the name of your database container (in this case, it would be <code>db</code>). The output will be a <code>.sql</code> file with a timestamp in its filename.
cat your_backup.sql | docker exec -i db psql -U wikijs
</pre>


After updating, make sure to verify that everything is running correctly. You can check the logs of your Wiki.js container with:
* Replace `your_backup.sql` with the actual path to your backup file.


<syntaxhighlight lang="shell">docker logs wiki</syntaxhighlight>
== Best Practices ==
If you encounter any issues, you can revert to the previous version using the backup you created earlier. For example:


<syntaxhighlight lang="shell">cat your_backup.sql | docker exec -i your-db-container psql -U wikijs</syntaxhighlight>
* Always test updates in a non-production environment to avoid disruption to live users.
Replace <code>your_backup.sql</code> with the path to your backup file and <code>your-db-container</code> with the name of your database container.
* Ensure the backup is valid and retrievable before making changes.
* Monitor the logs for any errors post-update to take corrective actions quickly.


Remember that updating is an important task that maintains system security and introduces new features and improvements. But also remember that it should be performed carefully, as it can potentially disrupt service. Always make sure to first test updates in an environment that does not affect live users./n
[[Category:Docker]]
[[Category:Self-Hosting]]
[[Category:Wiki.js]]
[[Category:Guides]]

Latest revision as of 19:00, 3 December 2024

Configure Wiki.js with Docker Compose

Using Docker Compose simplifies the process of updating Wiki.js while ensuring safe practices. This is a matter of personal preference, but it's a highly recommended approach for managing Dockerized services.

Configure Wiki.js

Create the following docker-compose.yml file in a user home directory for Wiki.js. Refer to the Linux Server Initial Setup guide for preliminary server setup.

version: "3"
services:

  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: wiki
      POSTGRES_PASSWORD: super_secret_here
      POSTGRES_USER: wikijs
    logging:
      driver: "none"
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data

  wiki:
    image: ghcr.io/requarks/wiki:2
    depends_on:
      - db
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: super_secret_here
      DB_NAME: wiki
    restart: unless-stopped
    ports:
      - "XZY:3000"

volumes:
  db-data:
  • Update the port where it says `XZY` (e.g., `80:3000` for typical use). If using self-host-cloudflare-tunnels, adjust to your desired port.
  • Replace the placeholder passwords (`super_secret_here`) with secure values.

Run Wiki.js

To run Wiki.js, execute the following command:

docker compose up -d

Update Wiki.js

To safely update Wiki.js, use:

docker-compose pull && docker-compose up -d

This command will pull the latest images specified in your `docker-compose.yml` file and restart the containers in detached mode.

Backup Wiki.js

Backup your data before updating or making significant changes. Use the following command to create a database dump:

docker exec -t db pg_dumpall -c -U wikijs > dump_$(date +"%d-%m-%Y_%H-%M-%S").sql
  • Replace `db` with the name of your database container if it's different.

Verify the logs of your Wiki.js container after the update to ensure it’s running correctly:

docker logs wiki

To restore the backup if needed:

cat your_backup.sql | docker exec -i db psql -U wikijs
  • Replace `your_backup.sql` with the actual path to your backup file.

Best Practices

  • Always test updates in a non-production environment to avoid disruption to live users.
  • Ensure the backup is valid and retrievable before making changes.
  • Monitor the logs for any errors post-update to take corrective actions quickly.