chore: add readme for docker specifications

This commit is contained in:
Junior L. Botelho (JLB) 2023-02-12 16:19:22 -03:00
parent a0a3a904df
commit 377f9d00e3
No known key found for this signature in database
GPG Key ID: 6A25840754F2A524
1 changed files with 38 additions and 21 deletions

View File

@ -1,16 +1,30 @@
## Introduction
### [Introduction](https://github.com/juniorbotelho/librex/tree/docker/docker#introduction)
- [Running a docker container](https://github.com/juniorbotelho/librex/tree/docker/docker#running-a-docker-container)
- [Run a docker container from Docker Hub with `librex/librex:latest`](https://github.com/juniorbotelho/librex/tree/docker/docker#running-a-docker-container-from-docker-hub-with-)
- Run a docker container using the `docker-compose.yml` file
- Environments can be configured in docker container
- Docker version issues
- Building a docker image
- Support differents architectures
### Running a docker container
Dockerized Librex is a way to provide users with yet another way to self-host their own projects with a view to privacy. If you wish to help, please start by looking for bugs in used docker configurations.
### Run a docker container from Docker Hub with `librex/librex:latest`
To run librex in a docker container, you can simply use the command:
```sh
docker run -d --name librex \
-e TZ="America/New_York" \
-e CONFIG_GOOGLE_DOMAIN="com" \
-e CONFIG_GOOGLE_LANGUAGUE="en" \
-p 8080:8080 \
librex/librex:latest
docker run -d --name librex \
-e TZ="America/New_York" \
-e CONFIG_GOOGLE_DOMAIN="com" \
-e CONFIG_GOOGLE_LANGUAGUE="en" \
-p 8080:8080 \
librex/librex:latest
```
or with **`docker-compose.yml`**:
@ -37,6 +51,7 @@ services:
restart: unless-stopped
```
### Docker Version
If you are going to build your own docker image based on this repository, pay attention to your Docker version, because depending on how recent the installed version is, maybe you should use the `buildx` command instead of `build`.
@ -45,41 +60,43 @@ Docker <= 20.10: `docker build`
Docker > 20.10: `docker buildx build`
### Build
If you don't want to use the image that is already available on `docker hub`, then you can simply build the Dockerfile directly from the github repository using the command:
```sh
docker build https://github.com/hnhx/librex.git -t librex:latest
docker build https://github.com/hnhx/librex.git -t librex:latest
```
```sh
docker run -d --name librex \
-e CONFIG_GOOGLE_DOMAIN="com" \
-e CONFIG_GOOGLE_LANGUAGUE="en" \
-p 8080:8080 \
librex:latest
docker run -d --name librex \
-e CONFIG_GOOGLE_DOMAIN="com" \
-e CONFIG_GOOGLE_LANGUAGUE="en" \
-p 8080:8080 \
librex:latest
```
Or, instead of doing the build remotely, you still have the opportunity to `git clone` the repository, and build it locally with the command:
```sh
git clone https://github.com/hnhx/librex.git
cd librex/
docker build -t librex:latest .
git clone https://github.com/hnhx/librex.git
cd librex/
docker build -t librex:latest .
```
### Supported Architectures
Supported architectures for the official Librex images include the same ones supported by Alpine itself, which are typically denoted as `linux/386`, `linux/amd64`, `linux/arm/v6`. If you need support for a different architecture, such as 'linux/arm/v7', you can modify the 'Dockerfile' to use a more comprehensive base image like 'ubuntu:latest' instead.
Supported architectures for the official Librex images include the same ones supported by Alpine itself, which are typically denoted as `linux/386`, `linux/amd64`, `linux/arm/v6`. If you need support for a different architecture, such as `linux/arm/v7`, you can modify the 'Dockerfile' to use a more comprehensive base image like `ubuntu:latest` instead.
In this case, you must run the `build` process specifying the desired architecture as shown in the example below:
```sh
docker buildx build \
--no-cache \
--platform linux/arm/v7 \
--tag librex/librex:latest .
docker buildx build \
--no-cache \
--platform linux/arm/v7 \
--tag librex/librex:latest .
```
**OBS:** Keep in mind that this can cause some issues at build time, so you need to know a little about Dockerfiles to solve this problem for your specific case.