Skip to content

Commit

Permalink
linting and precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 12, 2023
1 parent fa38355 commit 07561b0
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 63 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crate
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ['https://paypal.me/mikenyegithub']
custom: ["https://paypal.me/mikenyegithub"]
39 changes: 17 additions & 22 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,36 @@ name: Linting
on:
push:
pull_request:
branches: [ master ]
branches: [master]

jobs:

shellcheck:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Pull koalaman/shellcheck:stable Image
run: docker pull koalaman/shellcheck:stable
- name: Run Shellcheck against shell scripts
run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/')
# docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*execline.*' {} \; | grep -v '/.git/')
- uses: actions/checkout@v4
- name: Pull koalaman/shellcheck:stable Image
run: docker pull koalaman/shellcheck:stable
- name: Run Shellcheck against shell scripts
run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/')
# docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*execline.*' {} \; | grep -v '/.git/')

hadolint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Pull hadolint/hadolint:latest Image
run: docker pull hadolint/hadolint:latest
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3008 $(find . -type f -iname "Dockerfile*")
- uses: actions/checkout@v4
- name: Pull hadolint/hadolint:latest Image
run: docker pull hadolint/hadolint:latest
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3008 $(find . -type f -iname "Dockerfile*")

markdownlint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Pull markdownlint/markdownlint:latest Image
run: docker pull markdownlint/markdownlint:latest
- name: Run markdownlint against *.md files
run: docker run --rm -i -v "$(pwd)":/workdir --workdir /workdir markdownlint/markdownlint:latest --rules ~MD013 $(find . -type f -iname '*.md' | grep -v '/.git/')

- uses: actions/checkout@v4
- name: Pull markdownlint/markdownlint:latest Image
run: docker pull markdownlint/markdownlint:latest
- name: Run markdownlint against *.md files
run: docker run --rm -i -v "$(pwd)":/workdir --workdir /workdir markdownlint/markdownlint:latest --rules ~MD013 $(find . -type f -iname '*.md' | grep -v '/.git/')
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit-updates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Update pre-commit hooks

on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: vrslev/[email protected]
- uses: peter-evans/create-pull-request@v5
with:
branch: pre-commit-autoupdate
title: "chore(deps): Update pre-commit hooks"
commit-message: "chore(deps): Update pre-commit hooks"
body: Update pre-commit hooks
labels: dependencies
delete-branch: True
65 changes: 65 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
repos:
# lint yaml, line and whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: mixed-line-ending
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable

# lint the dockerfiles
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint

# prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3" # Use the sha / tag you want to point at
hooks:
- id: prettier
types_or: [file, bash, sh, javascript, jsx, ts, tsx]
additional_dependencies:
- [email protected]
exclude: ^(Dockerfile*)

- repo: https://github.com/codespell-project/codespell.git
rev: "v2.2.5" # Use the sha / tag you want to point at
hooks:
- id: codespell
types: [text]
args: [--ignore-words=.dictionary.txt]
exclude: ^(Dockerfile*)

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.27.0
hooks:
- id: check-github-actions
- id: check-github-workflows

- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check

# lint python formatting
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black

- repo: https://github.com/pycqa/flake8
rev: "6.1.0" # pick a git hash / tag to point to
hooks:
- id: flake8
args: ["--extend-ignore=W503,W504,E501"]
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ENV BASESTATIONPORT="30003" \

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# hadolint ignore=DL3008,SC2086,SC2039,SC2068
RUN set -x && \
apt-get update -y && \
apt-get install -y --no-install-recommends \
Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ docker run -d \

On the first run of the container, the database will be created & populated and data will be downloaded from the internet. This process can take quite some time. On my system, around 30 minutes. Once the first run processes are finished, to access FlightAirMap, you can:

* Browse to `http://dockerhost:8080/` to access the FlightAirMap GUI.
* Browse to `http://dockerhost:8080/install/` to access the FlightAirMap settings area.
- Browse to `http://dockerhost:8080/` to access the FlightAirMap GUI.
- Browse to `http://dockerhost:8080/install/` to access the FlightAirMap settings area.

With regards to settings - where one exists, you should use an environment variable to set your desired setting. The environment variables get written to the `require/settings.php` file on container start, so any configuration items applied via `/install/` area may be overwritten. Long story short, your first port of call for configuration should be environment variables.

Expand All @@ -60,14 +60,13 @@ With regards to settings - where one exists, you should use an environment varia
An example `docker-compose.yml` file is as follows:

```yaml
version: '2.0'
version: "2.0"

volumes:
fam_db:
fam_webapp:

services:

flightairmap:
image: mikenye/flightairmap:latest
tty: true
Expand All @@ -86,8 +85,8 @@ services:
On the first run of the container, the database will be created & populated and data will be downloaded from the internet. This process can take quite some time. On my system, around 30 minutes. Once the first run processes are finished, to access FlightAirMap, you can:
* Browse to `http://dockerhost:8080/` to access the FlightAirMap GUI.
* Browse to `http://dockerhost:8080/install/` to access the FlightAirMap settings area.
- Browse to `http://dockerhost:8080/` to access the FlightAirMap GUI.
- Browse to `http://dockerhost:8080/install/` to access the FlightAirMap settings area.

With regards to settings - where one exists, you should use an environment variable to set your desired setting. The environment variables get written to the `require/settings.php` file on container start, so any configuration items applied via with `/install/` area may be overwritten. Long story short, your first port of call for configuration should be environment variables.

Expand All @@ -98,7 +97,7 @@ With regards to settings - where one exists, you should use an environment varia
An example `docker-compose.yml` file is as follows:

```yaml
version: '2.0'
version: "2.0"
volumes:
fam_db:
Expand All @@ -108,7 +107,6 @@ networks:
flightairmap:
services:
flightairmap_db:
image: mariadb
command: --default-authentication-plugin=mysql_native_password
Expand Down Expand Up @@ -151,15 +149,15 @@ services:

On the first run of the container, the database will be created & populated and data will be downloaded from the internet. This process can take quite some time. On my system, around 30 minutes. Once the first run processes are finished, to access FlightAirMap, you can:

* Browse to `http://dockerhost:8080/` to access the FlightAirMap GUI.
* Browse to `http://dockerhost:8080/install/` to access the FlightAirMap settings area.
- Browse to `http://dockerhost:8080/` to access the FlightAirMap GUI.
- Browse to `http://dockerhost:8080/install/` to access the FlightAirMap settings area.

With regards to settings - where one exists, you should use an environment variable to set your desired setting. The environment variables get written to the `require/settings.php` file on container start, so any configuration items applied via with `/install/` area may be overwritten. Long story short, your first port of call for configuration should be environment variables.

### Environment Variables

To customize some properties of the container, the following environment
variables can be passed via the `-e` parameter (one for each variable). Value
variables can be passed via the `-e` parameter (one for each variable). Value
of this parameter has the format `<VARIABLE_NAME>=<VALUE>`.

`TZ`: Your local timezone in "TZ database name" format [List-of-tz-database-time-zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). Default `UTC`. Optional.
Expand Down Expand Up @@ -252,31 +250,31 @@ If you wish to use an external database:

### Data Volumes

The following table describes data volumes used by the container. The mappings
are set via the `-v` parameter. Each mapping is specified with the following
The following table describes data volumes used by the container. The mappings
are set via the `-v` parameter. Each mapping is specified with the following
format: `<VOL_NAME>:<CONTAINER_DIR>[:PERMISSIONS]`.

| Container path | Permissions | Description |
|-----------------|-------------|-------------|
|`/var/lib/mysql`| rw | This is where the application database resides, if using the internal database. |
|`/var/www/flightairmap`| rw | This is where the application itself resides. |
| Container path | Permissions | Description |
| ----------------------- | ----------- | ------------------------------------------------------------------------------- |
| `/var/lib/mysql` | rw | This is where the application database resides, if using the internal database. |
| `/var/www/flightairmap` | rw | This is where the application itself resides. |

It is suggested to make docker volumes for both of these areas, with the `docker volume create` command, and assign the volumes to the paths above.

### Ports

Here is the list of ports used by the container. They can be mapped to the host
via the `-p` parameter (one per port mapping). Each mapping is defined in the
following format: `<HOST_PORT>:<CONTAINER_PORT>`. The port number inside the
Here is the list of ports used by the container. They can be mapped to the host
via the `-p` parameter (one per port mapping). Each mapping is defined in the
following format: `<HOST_PORT>:<CONTAINER_PORT>`. The port number inside the
ainer cannot be changed, but you are free to use any port on the host side.

| Container Port | Purpose |
|----------------|---------|
| 80 (tcp) | FlightAirMap application, web server |
| Container Port | Purpose |
| -------------- | -------------------------------------------------------------------------------------------------------- |
| 80 (tcp) | FlightAirMap application, web server |
| 9999 (udp) | [ACARS UDP Messages](https://github.com/valeriosouza/FlightAirMap#acars-only-messages-from-real-flights) |

## Getting Help

Having troubles with the container or have questions? Please [create a new issue](https://github.com/mikenye/docker-flightairmap/issues).
Having troubles with the container or have questions? Please [create a new issue](https://github.com/mikenye/docker-flightairmap/issues).

I also have a [Discord channel](https://discord.gg/sTf9uYF), feel free to [join](https://discord.gg/sTf9uYF) and converse.
1 change: 0 additions & 1 deletion rootfs/etc/nginx/conf.d/flightairmap.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ server {
}
include /etc/nginx/flightairmap-nginx-conf.include;
}

2 changes: 1 addition & 1 deletion rootfs/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

user flightairmap;

pid /var/run/nginx.pid;
pid /var/run/nginx.pid;

# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;
Expand Down
14 changes: 7 additions & 7 deletions rootfs/etc/php/7.4/fpm/pool.d/flightairmap.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ listen = 127.0.0.1:9000
; process.priority = -19

; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
; or group is differrent than the master process user. It allows to create process
; or group is different than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes
Expand Down Expand Up @@ -139,7 +139,7 @@ pm.max_spare_servers = 3
;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
; recognized as a status page. It shows the following information:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
Expand Down Expand Up @@ -209,8 +209,8 @@ pm.max_spare_servers = 3
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; If the process is in Idle state, then information are related to the
; last request the process has served. Otherwise information are related to
; the current request being served.
; Example output:
; ************************
Expand Down Expand Up @@ -269,13 +269,13 @@ pm.max_spare_servers = 3
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{milliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; variable. Some examples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
Expand Down Expand Up @@ -374,7 +374,7 @@ pm.max_spare_servers = 3

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; Note: on highloaded environment, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
Expand Down
1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/daemon-acars
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
# shellcheck shell=sh

s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-acars.php 2>&1 | awk '{print "[daemon-acars] " $0}'

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/daemon-spotter
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
# shellcheck shell=sh

s6-setuidgid "$WEBUSER" php /var/www/flightairmap/htdocs/scripts/daemon-spotter.php 2>&1 | awk '{print "[daemon-spotter] " $0}'

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/nginx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
# shellcheck shell=sh

/usr/sbin/nginx 2>&1 | awk '{print "[nginx] " $0}'

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/php-fpm
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
# shellcheck shell=sh

/usr/sbin/php-fpm7.4 --nodaemonize 2>&1 | awk '{print "[php-fpm] " $0}'

5 changes: 2 additions & 3 deletions rootfs/etc/s6-overlay/scripts/socat
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# shellcheck shell=sh

if [ -z "${BASESTATIONHOST}" ]; then
sleep 3600
sleep 3600
else
# shellcheck disable=SC2153
# shellcheck disable=SC2153
socat -d -d TCP-LISTEN:30003,fork TCP:"${BASESTATIONHOST}":"${BASESTATIONPORT}"
fi

0 comments on commit 07561b0

Please sign in to comment.