[docker 를 이용해 mysql + redmine 설치]


* docker-compose 사용


(docker-compose-redmine.yaml)



version: '2.1'

services:
redmine:
image: redmine
restart: always
container_name: redmine
ports:
- 3000:3000
environment:
REDMINE_DB_MYSQL: db
REDMINE_DB_PASSWORD: pass
REDMINE_DB_DATABASE: redmine
REDMINE_DB_ENCODING: utf8
depends_on:
db:
condition: service_healthy

db:
image: mysql
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: redmine
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci



$ docker-compose -f docker-compose-redmine.yaml up -d


위 상태로 실행하면 redmine 이 실행되었다가 계속 restart 를 반복합니다.


mysql 은 잘 실행되지만 redmine 이 실행 도중 오류가 발생하는 것으로 보이는데..


$ docker logs -f redmine


redmine 로그를 확인해보면 


' Authentication plugin 'caching_sha2_password' cannot be loaded '


위와 같은 오류를 확인할 수 있습니다.


검색 해 본 결과 mysql 버전에 따른 오류라고 하는데요...

(https://stackoverflow.com/questions/49979089/authentication-plugin-caching-sha2-password-cannot-be-loaded-in-circleci-mysql)


그래서 mysql 버전을 5.7 버전으로 지정해서 설치하니까 잘 됩니다.


image: mysql    ->   image: mysql:5.7




version: '2.1'

services:
redmine:
image: redmine
restart: always
container_name: redmine
ports:
- 3000:3000
environment:
REDMINE_DB_MYSQL: db
REDMINE_DB_PASSWORD: pass
REDMINE_DB_DATABASE: redmine
REDMINE_DB_ENCODING: utf8
depends_on:
db:
condition: service_healthy

db:
image: mysql:5.7
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: redmine
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci




[추가사항]


혹시나 해서 mysql 대신 mariadb 로 하니까 최신버전이어도 잘 되는듯 합니다.


image: mariadb


(mariadb 만세)


[주사위 던지기용 소스]


* Terrain 태그 = Ground, 큐브가 Ground 에 닿아있을 때만 클릭으로 큐브를 던질 수 있음

* 큐브 inspector 에서 position x,z 값 고정하여 다른 방향으로 움직이지 않고 오직 위아래로만 움직이게끔 만듬



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cubeMove : MonoBehaviour {

public int speed = 10;
public bool isJumpping = false;

private Rigidbody rb;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
    }
    
    // Update is called once per frame
    void Update () {
moveCube();
}

void moveCube()
{
if (!isJumpping)
{
if (Input.GetMouseButtonDown(0))
{
this.isJumpping = true;
transform.position = new Vector3(50,1,50);
transform.rotation = Quaternion.identity;
rb.AddForce(transform.up * 500);
rb.AddTorque(Random.Range(0,500), Random.Range(0, 500), Random.Range(0, 500));
this.GetComponent<Rigidbody>().velocity = Vector3.up * this.speed;
}
}
}


private void OnCollisionEnter(Collision collision)
{
if (collision.transform.tag == "Ground")
{
this.isJumpping = false;
}
}

}





[GoLang 에서 json 사용하기]


* struct 구조체 선언시 변수명의 첫글자는 반드시 대문자여야 합니다.

* omitempty 입력 시 앞 쉼표 사이에 빈칸은 넣지 않으며 (넣으면 단순 경고 표시 발생)

  설정하게 되면 json 객체를 생성할때 해당 필드에 값이 없을 경우에만 필드를 변환하지 않고 건너뜁니다.

* `json:"-"` 설정 시 해당 필드는 무조건 변환되지 않습니다.



[예제 소스]


package main

import (
    "encoding/json"
    "fmt"
)

// Data is data
type Data struct {
    Name string `json:"Name"`
    Age int `json:"Age"`
    Etc1 string `json:"Etc1,omitempty"`
    Etc2 string `json:"Etc2,omitempty"`
    Temp string `json:"-"`
}

func main() {

    var jobj = Data{Name: "aaa", Age: 19, Etc1: "bbb", Etc2: "", Temp: "1123123"}
    jstrbyte, _ := json.Marshal(jobj)
    fmt.Println("---- jobj")
    fmt.Println(jobj)
    fmt.Println()
    fmt.Println("---- jstrbyte")
    fmt.Println(jstrbyte)
    fmt.Println()
    fmt.Println("---- string(jstrbyte)")
    fmt.Println(string(jstrbyte))
    fmt.Println()

    var jobj2 Data
    err := json.Unmarshal(jstrbyte, &jobj2)
    if err != nil {
        fmt.Println(err.Error())
    }
    fmt.Println("---- jobj2")
    fmt.Println(jobj2)
    fmt.Println()
    fmt.Println("---- jobj2.Name, jobj2.Age, jobj2.Etc1, jobj2.Etc2")
    fmt.Println(jobj2.Name, jobj2.Age, jobj2.Etc1, jobj2.Etc2)
    fmt.Println()

}



[결과]


* "omitempty", "-" : 두 설정 결과


---- jobj
{aaa 19 bbb 1123123}

---- jstrbyte
[123 34 78 97 109 101 ...... 98 98 98 34 125]

---- string(jstrbyte)
{"Name":"aaa","Age":19,"Etc1":"bbb"}

---- jobj2
{aaa 19 bbb }

---- string(jstrbyte)
{"Name":"aaa","Age":19,"Etc1":"bbb"}

---- jobj2.Name, jobj2.Age, jobj2.Etc1, jobj2.Etc2
aaa 19 bbb


+ Recent posts