Skip to content

Use a Docker image and start it with MySQL as the DB

Introduction

This procedure assumes that you can use the official Pleasanter Docker image, change the parameter file, and start it as described in the following two manuals.
1. Launch with Docker
2. Use a Docker Image and Start It by Changing the Parameters from the Default

If you have not read them, please refer to the above manuals first and make sure that you can use the official Pleasanter Docker image, change the parameter file, and start it.

Limitations

  1. When using a Docker image with MySQL, the version of Pleasanter must be 1.4.10.0 onward. Pleasanter has supported MySQL since version 1.4.9.0, but this procedure can only be performed with version 1.4.10.0 onward.

Prerequisites

  1. This procedure uses MySQL as the database. For instructions on using PostgreSQL, see "Launch with Docker" and "Use a Docker Image and Start It by Changing the Parameters from the Default".

Additional Docker Settings Required When Using MySQL

In this procedure, the container will be started with MySQL specified as the Pleasanter DB using the following settings.

  1. Change the contents of "Rds.json" to the description for MySQL.
  2. Register the connection string for MySQL in the environment variables of the Pleasanter (and CodeDefiner) container.

Also, make the following settings required for using MySQL.

  1. Write the SQL for creating a MySQL user account. (The SQL is automatically executed when the MySQL container is started.)
  2. To prevent errors when starting Pleasanter (and CodeDefiner), write a setting in the compose.yaml file to check whether MySQL has started up.

1. File Placement

Configure the folders as follows and place the files.

.
|-- compose.yaml
|-- .env
|
+-- app_data_parameters
|   +-- Folder for extensions
|   |   +-- Files for extensions
|   |  
|   +-- Parameter files
|
+-- docker-entrypoint-initdb.d
|   +-- pleasanter.sql
|
+-- CodeDefiner
|   +-- Dockerfile
|
+---Pleasanter
    +-- Dockerfile

1-1. app_data_parameters folder

Deploy "Rds.json" and the parameter file you want to change from the default value by following the steps below.

  1. Download Pleasanter from the Download Center. Download the latest version unless there is a special reason. If you need a specific version released in the past, download the appropriate version of Pleasanter.
  2. Unzip the zip file.
  3. Copy "\pleasanter\Implem.Pleasanter\App_Data\Parameters\Rds.json" from the unzipped folder to the app_data_parameters folder.
  4. Edit the copied "Rds.json", change the database server to MySQL, and save it.
  5. If you want to change other parameters from the default value, store the changed parameter file in the app_data_parameters folder.

Below is an example of how to modify "Rds.json".

{
    "Dbms": "MySQL",
    "Provider": "Local",
    "SaConnectionString": null,
    "OwnerConnectionString": null,
    "UserConnectionString": null,
    "SqlCommandTimeOut": 0,
    "MinimumTime": 3,
    "DeadlockRetryCount": 4,
    "DeadlockRetryInterval": 1000,
    "DisableIndexChangeDetection": true,
    "SysLogsSchemaVersion": 2
}

1-2. CodeDefiner folder

Create /CodeDefiner/Dockerfile with the following contents.

FROM implem/pleasanter:codedefiner

COPY app_data_parameters/ /app/Implem.Pleasanter/App_Data/Parameters/
ENTRYPOINT [ "dotnet", "Implem.CodeDefiner.dll" ]

1-3. Pleasanter folder

Create /Pleasanter/Dockerfile with the following content.

ARG VERSION=latest
FROM implem/pleasanter:${VERSION}

COPY app_data_parameters/ App_Data/Parameters/
ENTRYPOINT [ "dotnet", "Implem.Pleasanter.dll" ]

1-4 .env file

Create an .env file.

Of the environment variables required for the official MySQL Docker image, this procedure describes MYSQL_ROOT_PASSWORD, which is the password setting destination for the default superuser account (root).

mysql - Official Image | Docker Hub
docker-library/mysql: Docker Official Image packaging for MySQL Community Server

Name Body
MYSQL_ROOT_PASSWORD Specify an arbitrary password string

Prepare the environment variable PLEASANTER_VER and specify the version of Pleasanter.

Name Body
PLEASANTER_VER For {{Version}}, specify the version of Pleasanter published on DockerHub. (Example: latest, 1.4.10.1, etc.)
The version value must match the version of the parameter file to be deployed in the "1-1. app_data_parameters folder" mentioned above.

SaConnectionString is a single line that describes the settings for connecting to MySQL as a superuser. The contents of the MySQL environment variables must match the contents of SaConnectionString.

Name Body
Server Specify the service name (db) in the Compose file
Database Specify the default system database name (mysql) for MySQL
UID Specify the default superuser name (root) for MySQL
PWD Make the same as the MYSQL_ROOT_PASSWORD environment variable

OwnerConnectionString and UserConnectionString are single lines that describe the settings for connecting as each user.

Name Body
PWD Any password string. It is recommended that the Owner and User passwords are different.

This is an example of an actual file. Please modify {{ ... }} as appropriate.

MYSQL_ROOT_PASSWORD={{Sa Password}}
PLEASANTER_VER={{Version}}
Implem_Pleasanter_Rds_MySQL_SaConnectionString='Server=db;Database=mysql;UID=root;PWD={{Sa password}}'
Implem_Pleasanter_Rds_MySQL_OwnerConnectionString='Server=db;Database=#ServiceName#;UID=#ServiceName#_Owner;PWD={{Owner password}}'
Implem_Pleasanter_Rds_MySQL_UserConnectionString='Server=db;Database=#ServiceName#;UID=#ServiceName#_User;PWD={{User password}}'

1-5. docker-entrypoint-initdb.d folder

Description

This folder is automatically mounted in the "docker-entrypoint-initdb.d" directory of the MySQL container by the "volumes" setting under the "db" service in the compose.yaml file described later.

The SQL commands written in the files in the "docker-entrypoint-initdb.d" directory mounted in the container are automatically executed when the MySQL container starts.

Body of the SQL to be written

Below is an example of the "pleasanter.sql" file to be placed in the docker-entrypoint-initdb.d folder.

create user 'Implem.Pleasanter_Owner'@'%' identified by '{{Owner password}}';
grant all on `Implem.Pleasanter`.* to 'Implem.Pleasanter_Owner'@'%' with grant option;
create user 'Implem.Pleasanter_User'@'%' identified by '{{User password}}';
grant select, insert, update, delete, create routine, alter routine on `Implem.Pleasanter`.* to 'Implem.Pleasanter_User'@'%';

In the above example, the database name for Pleasanter is specified as "Implem.Pleasanter", which is the default value of "Name" in "Service.json". If you change "Name" in "Service.json" from the default value, make sure that the part where the database name is specified in the SQL statement (the "Implem.Pleasanter" part above) is the same as the part where "Name" in "Service.json" is changed.

Also, make sure that the password string for each MySQL user account specified after "identified by" matches the password in the .env file above.

1-6 compose.yaml file

Create a compose.yaml file.

services:
  db:
    container_name: mysql
    image: mysql:8.4
    environment:
      - MYSQL_ROOT_PASSWORD
    volumes:
      - type: volume
        source: my_data
        target: /var/lib/mysql
      - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
    healthcheck:
        test: mysqladmin ping -h 127.0.0.1 -u root -p${MYSQL_ROOT_PASSWORD}
        interval: 10s
        timeout: 10s
        retries: 6
  pleasanter:
    build:
      context: .
      dockerfile: ./Pleasanter/Dockerfile
      args:
        - VERSION=${PLEASANTER_VER}
    container_name: pleasanter_${PLEASANTER_VER}
    depends_on:
      db:
        condition: service_healthy
    ports:
      - '50001:8080'
    environment:
      Implem.Pleasanter_Rds_MySQL_SaConnectionString: ${Implem_Pleasanter_Rds_MySQL_SaConnectionString}
      Implem.Pleasanter_Rds_MySQL_OwnerConnectionString: ${Implem_Pleasanter_Rds_MySQL_OwnerConnectionString}
      Implem.Pleasanter_Rds_MySQL_UserConnectionString: ${Implem_Pleasanter_Rds_MySQL_UserConnectionString}
  codedefiner:
    build:
      context: .
      dockerfile: ./CodeDefiner/Dockerfile
    container_name: codedefiner
    depends_on:
      db:
        condition: service_healthy
    environment:
      Implem.Pleasanter_Rds_MySQL_SaConnectionString: ${Implem_Pleasanter_Rds_MySQL_SaConnectionString}
      Implem.Pleasanter_Rds_MySQL_OwnerConnectionString: ${Implem_Pleasanter_Rds_MySQL_OwnerConnectionString}
      Implem.Pleasanter_Rds_MySQL_UserConnectionString: ${Implem_Pleasanter_Rds_MySQL_UserConnectionString}
volumes:
  my_data:
    name: ${COMPOSE_PROJECT_NAME:-default}_my_data_volume

2. Build the container image

Execute the following command.

docker compose build

3. Run CodeDefiner

Execute the following command:

docker compose run --rm codedefiner _rds /l "<language>" /z "<timezone>"
Arguments e.g. Description
/l ja Rewrites the DefaultLanguage value in Service.json (*1)
/z Asia/Tokyo Rewrites the TimeZoneDefault value in Service.json (*1)

(*1) For language and time zone, please refer to the following manual page.
FAQ: I want to know the parameter settings for languages ​​and time zones supported by Pleasanter

If you are using a Japanese environment, use the following command.

docker compose run --rm codedefiner _rds /l "ja" /z "Asia/Tokyo"

If you see the message "Type "y" (yes) if the license is correct, otherwise type "n" (no)" during the process, enter y.

*The version will be output to the console log as shown below. The version displayed here will always be "the latest version of Pleasanter published on DockerHub." The specifications for this console log display are the same even if you specify a version older than the latest in the {{Version}} in the .env file, but the database will be created with content that complies with {{Version}}, so there will be no problems with Pleasanter's operation.

<INFO> Starter.Main: Implem.CodeDefiner 1.4.10.1

4. Start Pleasanter

Create a container and start Pleasanter.

docker compose up -d pleasanter

Access with a browser.

http://localhost:50001

Enter "Login ID: Administrator" and "Initial password: pleasanter" on the login screen. After logging in, you will be asked to change your password, so please set an appropriate password.

5. Stopping and Deleting Containers

Use the following command to stop a container.

docker compose stop

To restart a stopped container, run the following command:

docker compose start

DB data will not be deleted even if the container is stopped. The data will be available when restarting.


Use the following command to delete a container.
DB data (volumes) will not be deleted even if the container is deleted.

docker compose down

If you delete a container, you cannot restart it. If you want to start it, create a container.
Execute the following command. This will also create a DB container, and you will be able to use the remaining DB data as is.

docker compose up -d pleasanter

If you want to delete the data (volume) at the same time as deleting the container, run it with the option to delete the volume.

docker compose down -v

Supported Versions

Supported versions Body
1.4.10.0 onward Manual released to resolve issue where Owner and User connections were denied due to MySQL's access control function
*Pleasanter has been compatible with MySQL since version 1.4.9.0, but this procedure can only be performed on versions 1.4.10.0 onward.