Skip to content

Commit

Permalink
Merge pull request #26 from ecelis/feat/automate_fetch_release
Browse files Browse the repository at this point in the history
Feat/automate fetch release
  • Loading branch information
ecelis authored Dec 18, 2024
2 parents 5c81437 + 7ef22f1 commit 9eec935
Show file tree
Hide file tree
Showing 1,290 changed files with 157,792 additions and 13,669 deletions.
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM php:8.2.23-apache
ENV APACHE_DOCUMENT_ROOT /opt/ianseo
# Required dependencies
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
Expand All @@ -14,16 +15,17 @@ RUN apt-get update && apt-get install -y \
zlib1g zlib1g-dev \
libpng16-16 libpng-dev \
libonig5 libonig-dev \
&& pecl update-channels \
&& docker-php-ext-configure gd \
&& docker-php-ext-install gd \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install curl \
&& docker-php-ext-install mbstring \
&& docker-php-ext-install intl \
&& docker-php-ext-install zip
RUN /usr/bin/yes '' | /usr/local/bin/pecl install mcrypt-1.0.6
RUN /usr/bin/yes '' | /usr/local/bin/pecl install imagick
RUN apt-get remove \
&& docker-php-ext-install zip \
&& /usr/bin/yes '' | /usr/local/bin/pecl install mcrypt-1.0.6 \
&& /usr/bin/yes '' | /usr/local/bin/pecl install imagick \
&& apt-get remove \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
Expand All @@ -37,21 +39,17 @@ RUN apt-get remove \
libonig-dev \
apt-get clean all \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/* ; \
pecl update-channels ; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives ; \
rm -rf /usr/local/src ; \
rm -rf /tmp/pear ~/.pearrc
# ianseo setup
COPY src/ /opt/ianseo
RUN chmod -R a+wX /opt/ianseo
# Apache settings
ENV APACHE_DOCUMENT_ROOT /opt/ianseo
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \
RUN chmod -R a+wX /opt/ianseo \
&& sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \
/etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' \
/etc/apache2/apache2.conf /etc/apache2/conf-enabled/*.conf
COPY apache/ianseo.conf /etc/apache2/conf-enabled/
COPY apache/ianseo.ini /etc/apache2/conf-enabled/
COPY apache/ /etc/apache2/conf-enabled/
COPY php/php.ini /usr/local/etc/php
COPY php/docker-php-ext-ianseo.ini /usr/local/etc/php/conf.d
# COPY php/ianseo.config.inc.php /opt/ianseo/Common/config.inc.php
116 changes: 83 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,64 @@
# i@nseo
# Ianseo Docker container

i@nseo is a software for managing archery tournaments results
Ianseo is a software for managing archery tournaments results

This is an un-official repository, the official site for this software
is http://www.ianseo.net/

##### Ernesto Celis notes

Mine is a fork from Brian Nelson's `brian-nelson/ianseo` repository but
mixed with the official release, since Brian's repository seems
unmaintained.

This fork goal is running i@anseo in Docker containers. Docker setup is
out of scope.
## How to use with compose

## How to use this image

Copy `sample.env` to `.env` and edit to suit your requirements.
`compose.yaml`

```
cp sample.env .env`
services:
ianseodb:
image: mariadb:lts
environment:
- MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD:-ianseo}
- MARIADB_USER=${MARIADB_USER:-ianseo}
- MARIADB_DATABASE=${MARIADB_DATABASE:-ianseo}
- MARIADB_PASSWORD=${MARIADB_PASSWORD:-ianseo}
restart: always
ianseo:
image: arqueria/ianseo
ports:
- "8080:80"
depends_on:
- ianseodb
restart: always
```

### Run withDocker compose
Start the services in the background

```
docker compose up -d
```

### Run from command line, step by step
Browse to http://localhost:8080 and follow the instructions to
finish the installation.

⚠️ In the **Step 2: Database connection data** of ianseo has a default of
`localhost` for Database host, change it for the name of the MariaDB
container, `ianseodb` in the example above.

⚠️ Fill in the field for the **ADMIN Password to create users and databases**
with the value of the variable `MARIADB_ROOT_PASSWORD` of the MariaDB
container, `ianseo` in the example above.

### Run step by step

The following procedure assumes you created an `.env` file to store the required
environment variables values.

`.env`

```
MARIADB_ROOT_PASSWORD=ianseo
MARIADB_USER=ianseo
MARIADB_DATABASE=ianseo
MARIADB_PASSWORD=ianseo
```

First launch a MariaDB container.

Expand All @@ -45,14 +75,6 @@ docker run -d --name ianseo --link ianseodb:mysql -p 8080:80 arqueria/ianseo
Browse to http://127.0.0.1:8080 and follow the instructions to
finish the installation.

⚠️ In the **Step 2: Database connection data** of i@anseo has a default of
`localhost` for Database host, change it for the name of the MariaDB
container, `ianseodb` in the example above.

⚠️ Fill the field for the **ADMIN Password to create users and databases**
with the value of the variable `MARIADB_ROOT_PASSWORD` of the MAriaDB
container, `ianseo` in the example above.

## Environment Variables

One of `MARIADB_ROOT_PASSWORD`, `MARIADB_ALLOW_EMPTY_ROOT_PASSWORD`, or
Expand All @@ -62,7 +84,7 @@ variables are optional.
**MARIADB_ROOT_PASSWORD / MYSQL_ROOT_PASSWORD**

This specifies the password that will be set for the MariaDB root
superuser account. In the above example, it was set to my-secret-pw.
superuser account. In the above example, it was set to `ianseo`.

**MARIADB_ALLOW_EMPTY_ROOT_PASSWORD / MYSQL_ALLOW_EMPTY_PASSWORD**

Expand Down Expand Up @@ -97,37 +119,65 @@ by the `MARIADB_ROOT_PASSWORD` / `MYSQL_ROOT_PASSWORD` variable.
Refer to the MariaDB official repository for deeper information about
variable environments https://hub.docker.com/_/mariadb

## Fetch newer i@nseo releases
### .env file

You can use an `.env` file to store the required environment variables values.
Copy `sample.env` to `.env` and edit to suit your requirements.

```
cp sample.env .env`
```

## NodeJS development dependency

NodeJS is used to support some tasks related to maitaining the docker image. NodeJS is **NOT REQUIRED** to run ianseo in docker.

If you plan to contribute to this repository install NodeJS and required modules first.

```
npm install
```

## Fetch a newer ianseo releases

```
npm run ianseo:fetch <YYYYMMDD>
```

## Build the docker image

To only build the i@anseo image for the current CPU architechture run:
To build the ianseo image only for the current CPU architecture run:

```
npm run ianseo:build
```

To build images for both x86_64, aarch64 and arm7, run:
To build images for x86_64, aarch64 and arm7, run:

```
npm run ianseo:build:multi
```

## Relase and Publish images to Docker registries
## Release and Publish images to Docker registries

There are github actions wired to this repository, after mergin a branch into
`main` you must tag the commit to publish with semantic versioning.
Ex: v2022.01.01.1 vYEAR.MONTH.DAY.REVISION. Official I@anseo versioning has
integers as REVISION, however docker releases may add an alphabetic charater to
the REVISION integer to support my own releases linked to official ones.
Ex: v2022.01.01.1 `vYEAR.MONTH.DAY.REVISION`. Official Ianseo versioning has
integers as **REVISION**, however docker releases may add an alphabetic character
to the **REVISION** integer to support docker releases linked to official ones.

```
git checkout master
git checkout main
git pull
git tag v<YYYY>.<mm>.<dd>.<REVISION>
git push origin v<YYYY>.<mm>.<dd>.<REVISION>
```

##### Ernesto Celis notes

Mine is a fork from Brian Nelson's `brian-nelson/ianseo` repository but
mixed with the official release, since Brian's repository seems
unmaintained.

This fork goal is running ianseo in Docker containers. Docker setup is
out of scope.
93 changes: 93 additions & 0 deletions bin/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const https = require("https");
const fs = require("fs");
const path = require("path");
const unzipper = require("unzipper");

(async () => {
const IANSEO_URL = "https://ianseo.net";
let html = null;

const getHtml = () => {
https
.get(`${IANSEO_URL}/Releases.php`, (res) => {
let data = [];
console.log("Status Code:", res.statusCode);

res.on("data", (chunk) => {
data.push(chunk);
});

res.on("end", async () => {
html = Buffer.concat(data).toString();
const fileName = getFilename(html);
console.log(fileName);
if (fileName === null) {
throw new Error("No file found");
}
await downloadFile(fileName);
try {
await unzipFile(
path.join(__dirname, "..", fileName),
path.join(__dirname, "..", ".tmp")
);
} catch (err) {
throw new Error(err);
}
});
})
.on("error", (err) => {
console.log("Error: ", err.message);
});
};

const getFilename = (html) => {
const regex = /Ianseo_\d{8}\.zip/g;
const match = regex.exec(html);
if (match.length === 0) {
return null;
}
return match[0];
};

const downloadFile = async (fileName) => {
const url = `${IANSEO_URL}/Release/${fileName}`;
const filePath = path.join(__dirname, "..", fileName);

return new Promise((resolve, reject) => {
const file = fs.createWriteStream(filePath);
https
.get(url, (response) => {
if (response.statusCode !== 200) {
reject(
new Error(`Failed to get '${url}' (${response.statusCode})`)
);
return;
}

response.pipe(file);

file.on("finish", () => {
file.close(resolve);
});

file.on("error", (err) => {
fs.unlink(filePath, () => reject(err));
});
})
.on("error", (err) => {
fs.unlink(filePath, () => reject(err));
});
});
};

const unzipFile = async (zipFilePath, outputDir) => {
return new Promise((resolve, reject) => {
fs.createReadStream(zipFilePath)
.pipe(unzipper.Extract({ path: outputDir }))
.on("close", resolve)
.on("error", reject);
});
};

getHtml();
})();
6 changes: 3 additions & 3 deletions bin/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ then
echo "Usage: fetch.sh <YYYYMMDD>"
exit 1
fi
cd "${ROOT_DIR}"/src
ROOT_DIR=$(pwd)
ROOT_DIR=$(dirname $(readlink -f $0))/..
IANSEO_SRC=Ianseo_${1}.zip
curl -LSO https://ianseo.net/Release/"${IANSEO_SRC}"
mkdir -pv "${ROOT_DIR}"/tmp
cd "${ROOT_DIR}"/tmp
unzip "${ROOT_DIR}"/"${IANSEO_SRC}"
rsync -av --delete "${ROOT_DIR}"/tmp/ "${ROOT_DIR}"/src
cd "${ROOT_DIR}"
rm "${IANSEO_SRC}" ; rm -rf "${ROOT_DIR}"/tmp
rm "${IANSEO_SRC}"
rm -rf "${ROOT_DIR}"/tmp
11 changes: 6 additions & 5 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ services:
ianseodb:
image: mariadb:lts
environment:
- MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
- MARIADB_USER=${MARIADB_USER}
- MARIADB_DATABASE=${MARIADB_DATABASE}
- MARIADB_PASSWORD=${MARIADB_PASSWORD}
- MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD:-ianseo}
- MARIADB_USER=${MARIADB_USER:-ianseo}
- MARIADB_DATABASE=${MARIADB_DATABASE:-ianseo}
- MARIADB_PASSWORD=${MARIADB_PASSWORD:-ianseo}
restart: always
ianseo:
# image: ghcr.io/ecelis/ianseo-docker:v2023.04.01.562a
image: arqueria/ianseo
ports:
- "8080:80"
depends_on:
- ianseodb
# restart: always
Loading

0 comments on commit 9eec935

Please sign in to comment.