Skip to content

suteetoe/qnapsmldev

Repository files navigation

SMLDEV

Go

Build Docker จาก Code

FROM golang:1.10.3 as builder

WORKDIR /go/src/app
COPY . .
ADD . /go/src/goproject/

# install dependency
RUN go get -d -v ./...
# build go app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
# CMD ["app"] # if not step2 

# Setp 2 move to scratch
FROM alpine:latest

COPY --from=builder /go/src/app/app /
CMD ["/app"]

EXPOSE 80

Build แล้วเอาไป Run ใน Linux

สั่ง Build ด้วย Command

$ CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .

จะได้ app เอาไป run ใน linux

สร้าง Dockerfile สำหรับ เอาไป run ใน Linux

FROM scratch

ADD app /
CMD ["/app"]
EXPOSE 80

สั่ง build dockerfile

docker build -t <ชื่อ Image> .
docker run --name <ชื่อ Container> -p <port ข้างนอก>:<Port ใน image> -d <ชื่อ Image>

ตัวอย่าง

docker run --name <ชื่อ Container> -d -p 80:80

PostgreSQL

PostgreSQL Backup Command

pg_dump --host <ip> --port <port> --username "postgres" --format custom --blobs --verbose --file "<backuptofilename>" <databasename>

OR Linux

pg_dump -Fc <databasename> > outputfilename

PostgreSQL Restore Command

pg_restore.exe --host <ip> --port <port> --username "postgres" --dbname <database_name> --verbose <backupfile>

OR Linux

pg_restore --dbname <database_name> --verbose <backupfile>

Check Size Database & Table

select t1.datname AS db_name,  
       pg_size_pretty(pg_database_size(t1.datname)) as db_size
from pg_database t1
order by pg_database_size(t1.datname) desc;



SELECT
   relname as "Table",
   pg_size_pretty(pg_total_relation_size(relid)) As "Size",
   pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
   FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;

Move Database

pg_dump -C -h 192.168.2.98 -U postgres toc | psql -h localhost -U postgres toc

Install PostgreSQL With Replication

version: '3'

services:
 postgresql-master:
  image: docker.smldatacenter.com:5443/postgresql:10.4-replication
  container_name: postgresql_master
  restart: always
  environment:
   - POSTGRES_PASSWORD=<password>
  volumes:
   - ./master_data:/var/lib/postgresql/data
  ports:
   - 5432:5432
 postgresql-slave1:
  image: docker.smldatacenter.com:5443/postgresql:10.4-replication
  restart: always
  environment:
   - POSTGRES_MASTER_SERVICE_HOST=postgresql_master
   - REPLICATION_ROLE=slave
  volumes:
   - ./slave1_data:/var/lib/postgresql/data
  ports:
   - 54321:5432

PostgreSQL Docker Backup

version: '3'

services:
  postgresql-backup:
    image: smlsoft/smlpgbackup:10.4
    restart: always
    volumes:
      - ./backups:/var/lib/postgresql/backups
    environment:
      - BACKUPHOUR=22
      - BACKUPMINUTE=45
      - PGHOST=sml_postgresql

Option

Env Description
BACKUPHOUR เวลาที่จะทำการสำรองข้อมูล (0-23)
BACKUPMINUTE ระบุนาที
PGHOST ชื่อ Server เก็บข้อมูล (postgresql)
PGPORT Port
PGUSER รหัสผู้ใช้
PGPASS รหัสผ่าน

PostgreSQL Slave Config

<slaveserver>dev.smlsoft.com</slaveserver><slaveport>54329</slaveport><slaveuser>postgres</slaveuser><slavepassword>sml</slavepassword>

install

Service

My QNAP

qnapsmldev.myqnapcloud.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published