Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
No Format
WD=/opt/dcontainer
mkdir -p $WD/{dcontainer_sql,dcontainer_conf,setup}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.2'

services:
 dcontainer:
    container_name: dcontainer
    image: dcontainer
    hostname: dcontainer
    networks:
      - dcontainernet
    ports:
      - '6565:80'
    volumes:
      - type: bind
        source: /opt/dcontainer/dcontainer_conf/
        target: /etc/dcontainer

    environment:
      - 'TZ=America/Whitehorse'

 dcontainerdb:
    container_name: dcontainer_sql
    hostname: dcontainer_sql
    networks:
      - dcontainernet
    image: postgres
    volumes:
      - type: bind
        source: /opt/dcontainer/dcontainer_sql/
        target: /var/lib/postgresql/data

    environment:
      - 'POSTGRES_USER=${DB_USER}'
      - 'POSTGRES_PASSWORD=${DB_PWD}'
      - 'POSTGRES_DB=${DB_NAME}'
      - 'POSTGRES_ENCODING=UTF8'
      - 'POSTGRES_COLLATE=C'
      - 'POSTGRES_COLLATE_TYPE=C'

networks:
  dcontainernet:
    driver: bridge
EOF
chmod +x docker-compose.yaml

cd $WD/setup
cat << 'EOF'>.env
DB_NAME=dcontainer
DB_USER=dcontainer
DB_PWD=dcontainer
EOF
chmod +x .env
No Format
mkdir /opt/postgresql
cat << 'EOF' >/opt/postgresql/postgresql_docker.sh
docker run -d \
    --name postgresql \
    -v /opt/postgresql/data:/var/lib/postgresql/data \
    -v /opt/postgresql/mnt:/mnt \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -e POSTGRES_USER=postgres \
    -p 5432:5432 \
    postgres
EOF
chmod +x /opt/postgresql/postgresql_docker.sh
/opt/postgresql/postgresql_docker.sh

...