siteviewcounter/README.md

70 lines
1.6 KiB
Markdown
Raw Normal View History

2020-06-04 02:37:59 +00:00
# siteviewcounter
2020-06-04 02:40:13 +00:00
[![Build Status](https://drone.deadbeef.codes/api/badges/steven/siteviewcounter/status.svg)](https://drone.deadbeef.codes/steven/siteviewcounter)
A simple view counter for a website
### Database initialization
2020-06-21 02:30:09 +00:00
The following SQL will initialize the database for this application. No automigrate / initialization is done upon first running the application, so this must be ran by an administrator.
2020-06-04 02:40:13 +00:00
```sql
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
CREATE DATABASE `counter` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `counter`;
CREATE TABLE `visit` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip_address` varchar(15) NOT NULL,
`visits` int(11) NOT NULL,
`last_visited` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
```
2020-06-21 02:30:09 +00:00
### Build Container
Disclaimer! If you use this, you'll need to build the container yourself. My registry is used for my internal infrastructure only and is not publicly available.
2020-06-04 02:40:13 +00:00
### Example docker-compose.yml
2020-06-21 02:30:09 +00:00
Create a docker-compose file
2020-06-04 02:40:13 +00:00
```yaml
version: '3.7'
services:
counter:
image: registry.deadbeef.codes/siteviewcounter:latest
restart: always
depends_on:
- traefik
expose:
- "8080"
environment:
- dbname=counter
- dbhostname=counter-db
- dbusername=root
- dbpassword=CHANGEME
- timezone=America/Edmonton
counter-db:
image: mariadb:10
restart: always
expose:
- "3306"
volumes:
- /data/counter-db:/var/lib/mysql
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=counter
- TZ=America/Edmonton
```