Skip to content

Commit

Permalink
Fixes related to docker builds (#57)
Browse files Browse the repository at this point in the history
* Now spawns without issue
* MySQL initdb corrections may still be required
* Fixed minor docker issues
  • Loading branch information
bearlike committed Jul 11, 2022
1 parent 48b72ab commit 9f15888
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 88 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
@@ -0,0 +1,7 @@
# Project specific files
.github/
.git/
docs/
Dockerfile
*.log
.dockerignore
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,47 @@
name: Build and deploy multiarch image

on:
push:
tags:
- 'v*'
paths-ignore:
- 'docs/**'
workflow_dispatch:


jobs:
docker:
name: Build and push image
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
env:
IMG_NAME: ${{ 'krishnaalagiri/rems' }}
# Versioning: MAJOR.MINOR.PATCH (eg., 1.2.3)
VERSION_FULL: ${{ '1.1.6' }}
# For v1.2.3, VERSION_SHORT is '1.2'
VERSION_SHORT: ${{ '1.1' }}
# For v1.2.3, VERSION_MAJOR is '1'
VERSION_MAJOR: ${{ '1' }}
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMG_NAME }}:latest,${{ env.IMG_NAME }}:${{ env.VERSION_FULL }},${{ env.IMG_NAME }}:${{ env.VERSION_SHORT }},${{ env.IMG_NAME }}:${{ env.VERSION_MAJOR }}
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -26,3 +26,8 @@ members/secrets_.php
assets/img/avatars/users/*

members/test.php

# IDE specific files
.DS_Store
.vscode/
.idea/
18 changes: 12 additions & 6 deletions Dockerfile
@@ -1,15 +1,21 @@
# syntax=docker/dockerfile:1

FROM php:7.2-apache
LABEL in.thekrishna.rems.email="krishna.alagiri03@gmail.com"
LABEL in.thekrishna.rems.authors="Krishnakanth, Mahalakshumi"
LABEL in.thekrishna.rems.link="https://github.com/bearlike/REMS-For-Organisations"
LABEL in.thekrishna.rems.title="Resources and Event Management System (REMS)"

# Lablelling
LABEL com.rems.title="Resources and Event Management System (REMS)"
LABEL com.rems.version="1.1.6"
LABEL com.rems.authors="Krishnakanth, Mahalakshumi"
LABEL com.rems.repository="https://github.com/bearlike/REMS-For-Organisations"
LABEL com.rems.description="Resources and Event Management System for small organisations and clubs. Bulk mailer, certificate generation and much more."

# Installing dependencies
RUN rm /etc/apt/preferences.d/no-debian-php
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions gd xdebug
RUN install-php-extensions pdo_mysql

# Copying project and (template) secrets file
COPY . /var/www/html/
COPY docker/secrets_.php /var/www/html/members
RUN rm -r /var/www/html/docs /var/www/html/.git
COPY docker/secrets_.php /var/www/html/members
31 changes: 17 additions & 14 deletions README.md
Expand Up @@ -14,22 +14,12 @@
</p>



### Why are we doing it?
We are running a chapter (club) at our college. We organize 20+ events for our 1500+ participants. It was a tedious process to manually make forms, certificates, advertising via mail so we decided to automate that process. Any organization, clubs or institutions looking for a similar service can fork our project and tweak it according to their needs.


## Getting Started

### Running REMS in Docker (Easiest)
Modify the default values in `docker/mysql/database.sql` and `docker-run-vanilla.sh` to your requirement.
By default, exposes to host port `8080`. A `krishnaalagiri/rems` and `mysql` container would be configured and deployed.
```bash
# From the root of the repository
sudo chmod +x docker-run-vanilla.sh
./docker-run-vanilla.sh
```

### Prerequisites
What things you need to run the software:
- A **web server** with **PHP** preferably Apache2.
Expand All @@ -51,6 +41,19 @@ What things you need to run the software:
8. If any error occurs, check your configurations in `member/secrets.php` and `public/cds-public.php` and try again


### Running REMS as a Docker stack (Experimental).
- Installation guide for [Docker](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04) and [docker-compose](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-22-04).
- Modify the default values in `docker-compose.yml`, `docker/mysql/database.sql` and `docker/secrets_.php` to your requirement.
- By default, exposes to host port `8080`. A `krishnaalagiri/rems` and `mariadb` container would be configured and deployed.
- For only the first time, the stack needs to be restarted due `initdb` in database containers. From the second time, you can directly start the stack.
```bash
# From the root of the repository
docker-compose up -d
sleep 60
docker-compose restart
```


## Features and Screenshots (Click to enlarge)

```
Expand Down Expand Up @@ -116,10 +119,10 @@ Perhaps our most desired feature, it gives an option to toggle the page between

## Authors

| Krishnakanth Alagiri | Mahalakshumi V |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [![f](https://avatars1.githubusercontent.com/u/39209037?s=86)](https://github.com/bearlike) | [![f](https://avatars2.githubusercontent.com/u/40058339?s=86)](https://github.com/mahavisvanathan) |
| [@bearlike](https://github.com/bearlike) | [@mahavisvanathan](https://github.com/mahavisvanathan) |
| Krishnakanth Alagiri | Mahalakshumi V |
| ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [![f](https://avatars1.githubusercontent.com/u/39209037?s=86)](https://go.thekrishna.in/github) | [![f](https://avatars2.githubusercontent.com/u/40058339?s=86)](https://github.com/mahavisvanathan) |
| [@bearlike](https://go.thekrishna.in/github) | [@mahavisvanathan](https://github.com/mahavisvanathan) |


## Outside Contributors
Expand Down
71 changes: 43 additions & 28 deletions docker-compose.yml
@@ -1,38 +1,53 @@
# Docker compose file for bearlike/REMS-for-Organisations

# Docker build related issues can be raised here:
# * https://github.com/bearlike/REMS-For-Organisations/issues/new?labels=Docker

# Execute by running:
# docker-compose up -d

version: '3'

services:
rems-app:
image: krishna/rems:latest
ports:
- 8080:80
volumes:
- rems_gen_certs:/var/www/html/public/Generated Certificate
networks:
- rems-network

rems-mysql:
image: mysql
database:
image: mariadb:10.7.3-focal
restart: always
ports:
# We recommend commenting the ports block for increased security.
# Exposing the database port is intended only for debugging.
- 3306:3306
volumes:
- rems_mysql:/var/lib/mysql
- ./docker/mysql:/docker-entrypoint-initdb.d
- database_volume:/var/lib/mysql
- ./docker/mysql:/docker-entrypoint-initdb.d # Load SQL files during database creation
environment:
- MYSQL_ROOT_PASSWORD="0000"
- MYSQL_DATABASE="db_cms"
networks:
rems-network:
ipv4_address: 172.16.238.10
MYSQL_ROOT_PASSWORD: "0000"
MYSQL_PASSWORD: "0000"
MYSQL_DATABASE: "db_cms"
MYSQL_USER: "cmsuser"
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 15

networks:
rems-network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
app:
image: krishnaalagiri/rems:1.1.6
restart: on-failure
depends_on:
- database
ports:
# <host port>:<container port (default=80)>
- 8080:80
volumes:
# Replace generated_certificates_volume with an absolute path if you
# need direct access to the certificates. Usually not required.
- "generated_certificates_volume:/var/www/html/public/Generated Certificate"
- ./docker/secrets_.php:/var/www/html/members/secrets_.php
environment:
# * Edit docker/secrets_.php for other enviroiment variables.
MYSQL_HOST: database
MYSQL_PASSWORD: "0000"
MYSQL_USER: "cmsuser"

volumes:
rems_mysql:
rems_gen_certs:

database_volume:
generated_certificates_volume:
5 changes: 0 additions & 5 deletions docker-run-compose.sh

This file was deleted.

10 changes: 0 additions & 10 deletions docker-run-vanilla.sh

This file was deleted.

4 changes: 3 additions & 1 deletion docker/mysql/database.sql
Expand Up @@ -12,7 +12,9 @@ CREATE DATABASE IF NOT EXISTS `db_cms`;
CREATE DATABASE IF NOT EXISTS `db_forms`;
CREATE DATABASE IF NOT EXISTS `db_mailer`;

CREATE USER 'cmsuser'@'localhost' IDENTIFIED BY 'random_password';

-- Make sure the username and password are set right below.
CREATE USER 'cmsuser'@'localhost' IDENTIFIED BY '0000';
GRANT ALL ON *.* TO 'cmsuser'@'localhost';

-- --------------------------------------------------------------
Expand Down
51 changes: 27 additions & 24 deletions docker/secrets_.php
@@ -1,36 +1,39 @@
<?php
/* Fill in all these details to get your system up and running. Rename this file to secrets_.php */
/* Sample Values Filled */
$OrgName = 'SVCE-ACM';
$servername = '172.16.238.10'; // Name of server (Docker network IP)
$username = 'cmsuser'; // User name for the database
$password = 'random_password'; // Password for the database
$MainDB = 'db_cms'; // Name of the main database where all CMS information is stored (login, certificates, event information)
$formDB = "db_forms"; // Name of the database for recording generated form details
$mailerDB = "db_mailer"; // Name of the mailer database
$startPath = ''; // Leave it blank if the files are in the root location of your web server else fill in with the location
/* Secrets and enviroinment file for Docker instances. */

/* Sample Values Filled. You must alter to your preference, otherwise you
might have limited or no functionality */

$OrgName = 'SVCE-ACM'; // Name of the organisation
$servername = getenv('MYSQL_HOST'); // (Not recommended to change) Name of server.
$username = getenv('MYSQL_USER'); // (Not recommended to change) User name for the database.
$password = getenv('MYSQL_PASSWORD'); // (Not recommended to change) Password for the database.
$MainDB = 'db_cms'; // (Not recommended to change) Name of the main database where all CMS information is stored.
$formDB = "db_forms"; // (Not recommended to change) Name of the database for recording generated form details.
$mailerDB = "db_mailer"; // (Not recommended to change) Name of the mailer database.
$startPath = ''; // (Not recommended to change) Root of the platform.

/* Mailer Details */
$mailerHostname = "sample.host.name";
$mailerUname = "sample_mail@sample.host.name";
$mailerPassword = "sample_mail_password";
$mailerHostname = "sample.host.name"; // SMTP Hostname
$mailerUname = "sample_mail@sample.host.name"; // SMTP email username
$mailerPassword = "sample_mail_password"; // SMTP email password

/* Default mail template details */
$buttonLabel = "Click here"; // Label that is present in button
$buttonURL = "https://sample.org/"; // URL that button directs too
$logoURL = "https://sample.org/logo.png"; // URL for organisation logo in mail
$buttonLabel = "Click here"; // (Recommended) Label that is present in button
$buttonURL = "https://sample.org/"; // URL that button directs too
$logoURL = "https://sample.org/logo.png"; // URL for organisation logo in mail
$coverURL = "https://sample.org/cover.jpg"; // URL for organisation cover page in mail

/* Forgot Password section details */
$hostName = "localhost/domain/"; // Host name for local testing
// $hostName = "sample.host.name/"; // Host name for deployment
$forgotPwdExtension = "members/change-password.php"; //Path to change password page
$hostName = "localhost/domain/"; // Host name for local testing
// $hostName = "sample.host.name/"; // Host name for deployment
$forgotPwdExtension = "members/change-password.php"; //Path to change password page

/* Forgot Password Mail Template details */
$reachEmail = 'sample@sample.host.name'; // contact mail-id present in the forgot password email
$darkLogo = 'https://sample.logo/path'; // Path for organisation logo in forgot password mail
$logoHREF = "https://sample.org"; // Website that clicking on organisation logo leads to
$reachEmail = 'sample@sample.host.name'; // contact mail-id present in the forgot password email
$darkLogo = 'https://sample.logo/path'; // Path for organisation logo in forgot password mail
$logoHREF = "https://sample.org"; // Website that clicking on organisation logo leads to

/* API Keys */
$shortcm_authorization = "ABCDEFABCDEFABCDEFABCDEF"; // Visit https://short.io/features/api for more details
$shortcm_domain = "sample.domain"; // Domain for generating the shortened URL
$shortcm_authorization = "ABCDEFABCDEFABCDEFABCDEF"; // Visit https://short.io/features/api for more details
$shortcm_domain = "sample.domain"; // Domain for generating the shortened URL

0 comments on commit 9f15888

Please sign in to comment.