• 우연히 Mattermost 라는 solution을 알게됨
  • slack의 alternative가 될 수 있어 보임
  • 50인 이하, private network에서 동작 시 free로 사용 가능함
  • DB는 postgresql을 사용함
  • 여러 방법으로 설치가 가능하여 Docker 에 설치해 봄
  • https://docs.mattermost.com/install/install-docker.html
 

Deploy Mattermost via Docker - Mattermost documentation

Previous Install Mattermost Server on Ubuntu

docs.mattermost.com

 

  • github 에서 Docker 관련 파일들 clone 이후 약간의 추가 작업 필요함
    • .env 파일 생성
    • .env 약간 수정
    • 8065 포트만 forwarding을 해도 될 것도 같고... 귀찮아서 더이상은 안해봄
root@Ubuntu24:~/repos/mattermost-docker# git diff
diff --git a/docker-compose.yml b/docker-compose.yml
index dfdf345..9f3122d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -59,6 +59,11 @@ services:
 
       # additional settings
       - MM_SERVICESETTINGS_SITEURL
+    ports:
+      - "8065:8065"
+      - "8443:8443"
+      - "80:80"
+      - "443:443"

 

  • ServerIp:8065로 접속해서 기본 설정하니 잘 동작됨
  • 최초 접속 화면

 

  • 기본 설정 후 사용 가능함
    • GUI가 Slack 과 많이 비슷함

반응형
 

Ubuntu

Jumpstart your client-side server applications with Docker Engine on Ubuntu. This guide details prerequisites and multiple methods to install Docker Engine on Ubuntu.

docs.docker.com

 

  • Apt repository 추가
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

 

 

  •  설치
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

 

  • 확인
sudo docker run hello-world

 

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

 

  • 추가 정보
    • docker 설치 시 docker-compose가 같이 설치되는데 docker-compose 명령어는 /usr/libexec/docker/cli-plugins/docker-compose 라는 요상한 곳에 설치가 됨
    • 해당 path를 $PATH에 추가해도 좋겠지만...
    • 난 그냥 /usr/local/bin 에 심볼릭 링크 추가함
root@Ubuntu24:~# dpkg -L docker-compose-plugin
/.
/usr
/usr/libexec
/usr/libexec/docker
/usr/libexec/docker/cli-plugins
/usr/libexec/docker/cli-plugins/docker-compose
/usr/share
/usr/share/doc
/usr/share/doc/docker-compose-plugin
/usr/share/doc/docker-compose-plugin/changelog.Debian.gz
root@Ubuntu24:~# ls -al /usr/local/bin/
total 8
drwxr-xr-x  2 root root 4096 Nov 25 23:48 .
drwxr-xr-x 10 root root 4096 May  7  2024 ..
lrwxrwxrwx  1 root root   46 Nov 25 23:48 docker-compose -> /usr/libexec/docker/cli-plugins/docker-compose
root@Ubuntu24:~# docker-compose --help

Usage:  docker compose [OPTIONS] COMMAND

Define and run multi-container applications with Docker

Options:
      --all-resources              Include all resources, even those not used by services
      --ansi string                Control when to print ANSI control characters
                                   ("never"|"always"|"auto") (default "auto")
      --compatibility              Run compose in backward compatibility mode
      --dry-run                    Execute command in dry run mode
      --env-file stringArray       Specify an alternate environment file
  -f, --file stringArray           Compose configuration files
      --parallel int               Control max parallelism, -1 for unlimited (default -1)
      --profile stringArray        Specify a profile to enable
      --progress string            Set type of progress output (auto, tty, plain, json,
                                   quiet) (default "auto")
      --project-directory string   Specify an alternate working directory
                                   (default: the path of the, first specified, Compose file)
  -p, --project-name string        Project name

Commands:
  attach      Attach local standard input, output, and error streams to a service's running container
  build       Build or rebuild services
  config      Parse, resolve and render compose file in canonical format
  cp          Copy files/folders between a service container and the local filesystem
  create      Creates containers for a service
  down        Stop and remove containers, networks
  events      Receive real time events from containers
  exec        Execute a command in a running container
  images      List images used by the created containers
  kill        Force stop service containers
  logs        View output from containers
  ls          List running compose projects
  pause       Pause services
  port        Print the public port for a port binding
  ps          List containers
  pull        Pull service images
  push        Push service images
  restart     Restart service containers
  rm          Removes stopped service containers
  run         Run a one-off command on a service
  scale       Scale services 
  start       Start services
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop services
  top         Display the running processes
  unpause     Unpause services
  up          Create and start containers
  version     Show the Docker Compose version information
  wait        Block until containers of all (or specified) services stop.
  watch       Watch build context for service and rebuild/refresh containers when files are updated

Run 'docker compose COMMAND --help' for more information on a command.
root@Ubuntu24:~#
반응형
  • docker 설치 이후 직접 run을 시킬 경우 docker network이 달라 접속이 되지 않았음
  • Copilot 에게 다시 질문을 해보니 아래와 같이 해결책을 가르쳐 주었다.
    • 현재 docker-compose.yml 를 사용하고 있었는데 적절한 해결책을 제시해 줌
    • 새로운 해결책대로 수정을 해봤더니 바로 접속 성공!!!
     

반응형
 

Dockerize Wagtail & PostgreSQL as a development environment

If you want to develop with Wagtail and PostgreSQL in a platform-independent way, using Docker is a good choice. In the following tutorial, I would like to share my approach.

www.phooky.com

  • 아래와 같은 문제가 생겼다.
(.venv) ➜ projectGoguma (main) ✗ docker-compose exec web python manage.py createsuperuser --settings=projectGoguma.settings.dev

You have 162 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, home, sessions, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers.
Run 'python manage.py migrate' to apply them.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
                                                             ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 88, in execute
    return super().execute(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 109, in handle
    default_username = get_default_username(database=database)
  File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/management/__init__.py", line 168, in get_default_username
    auth_app.User._default_manager.db_manager(database).get(
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 633, in get
    num = len(clone)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 380, in __len__
    self._fetch_all()
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 1881, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 91, in __iter__
    results = compiler.execute_sql(
  File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 102, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
                                                             ^
  • 이리저리 다 수정을 한 것 같은데 왜 안될까???
  • docker container에 직접 attach를 해보니...
  • 엥???
(.venv) ➜ projectGoguma (main) ✗ docker ps -a
CONTAINER ID   IMAGE                  COMMAND                   CREATED              STATUS                   PORTS                                       NAMES
c281852e6c92   projectgoguma_web      "/app/entrypoint.sh …"   About a minute ago   Up About a minute        0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   projectgoguma_web_1
06f0d1750419   postgres:13.5-alpine   "docker-entrypoint.s…"   About a minute ago   Up About a minute        0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   projectgoguma_db_1
59ee14bdc489   hello-world            "/hello"                  3 weeks ago          Exited (0) 3 weeks ago                                               gallant_lamport
(.venv) ➜ projectGoguma (main) ✗ docker attach projectgoguma_web_1
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
/app/entrypoint.sh: 7: /app/entrypoint.sh: nc: not found
  • nc를 왜 필요로 하지?
  • 잘 모르겠지만 Dockerfile 에서 netcat 설치를 추가해 보니 문제 해결
# Install system packages required by Wagtail and Django.
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
    build-essential \
    libpq-dev \
    libmariadbclient-dev \
    libjpeg62-turbo-dev \
    zlib1g-dev \
    libwebp-dev \
    netcat \
    # environ \
    # postgresql-dev \
    # python3-dev \
    # musl-dev \
  • 잘된다.
(.venv) ➜ projectGoguma (main) ✗ docker-compose up -d --build                    
Building web
[+] Building 57.1s (14/14) FINISHED                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 2.50kB                                                                             0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 418B                                                                                  0.0s
 => [internal] load metadata for docker.io/library/python:3.8.1-slim-buster                                        1.3s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 70B                                                                                   0.0s
 => [1/9] FROM docker.io/library/python:3.8.1-slim-buster@sha256:73f3903470a6e55202a6bb989c23b047487eb1728feba655  0.0s
 => CACHED [2/9] RUN useradd wagtail                                                                               0.0s
 => [3/9] RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends     build-es  23.8s
 => [4/9] RUN pip install "gunicorn==20.0.4"                                                                       1.9s 
 => [5/9] COPY requirements.txt /                                                                                  0.1s 
 => [6/9] RUN pip install -r /requirements.txt                                                                    27.9s 
 => [7/9] WORKDIR /app                                                                                             0.0s 
 => [8/9] RUN chown wagtail:wagtail /app                                                                           0.3s 
 => [9/9] COPY entrypoint.sh /app/entrypoint.sh                                                                    0.0s 
 => exporting to image                                                                                             1.6s 
 => => exporting layers                                                                                            1.6s 
 => => writing image sha256:5f7b2c8cec2309bcf3f45e6a3938484c3d7c90b29cef5bcb0ffb787b14bbf6ef                       0.0s 
 => => naming to docker.io/library/projectgoguma_web                                                               0.0s
Creating projectgoguma_db_1 ... done
Creating projectgoguma_web_1 ... done
(.venv) ➜ projectGoguma (main) ✗ docker-compose exec web python manage.py createsuperuser --settings=projectGoguma.settings.dev
Username (leave blank to use 'wagtail'):
  • 떴다!!!

반응형

'django & Wagtail' 카테고리의 다른 글

Wagtail Tutorial  (0) 2023.08.14
Wagtail 설정 with postgreSql  (0) 2023.08.14

+ Recent posts