Create new Docker dev image (#1173) 1205/head
authoram97 <andy.maldo@hotmail.com>
Tue, 9 Oct 2018 15:35:02 +0000 (17:35 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 9 Oct 2018 15:35:02 +0000 (17:35 +0200)
* Move the old dev docker files to support/docker/janitor

* Create new Docker dev image

support/docker/dev/Dockerfile
support/docker/dev/create_user.sql [deleted file]
support/docker/dev/janitor.json [deleted file]
support/docker/dev/setup_postgres.sql [new file with mode: 0644]
support/docker/dev/supervisord.conf [deleted file]
support/docker/dev/usage.md [new file with mode: 0644]
support/docker/janitor/Dockerfile [new file with mode: 0644]
support/docker/janitor/create_user.sql [new file with mode: 0644]
support/docker/janitor/janitor.json [new file with mode: 0644]
support/docker/janitor/supervisord.conf [new file with mode: 0644]

index 2b4f2b215f74aa05870b0bc8bbc52e8682406140..aa4a8a3d6340ae592dc61a6f9dfaa3892cc62cfc 100644 (file)
@@ -1,32 +1,48 @@
-FROM janitortechnology/ubuntu-dev
+FROM ubuntu:bionic
+
+# Avoid tzdata interactive dialog
+ENV DEBIAN_FRONTEND=noninteractive
 
 # Install PeerTube's dependencies.
 # Packages are from https://github.com/Chocobozzz/PeerTube#dependencies
-RUN sudo apt-get update -q && sudo apt-get install -qy \
+RUN apt-get update -q && apt-get install -qy \
+ curl \
+ nano \
  ffmpeg \
  postgresql \
- openssl
+ postgresql-contrib \
+ openssl \
+ g++ \
+ make \
+ redis-server \
+ git \
+ gnupg
+
+# Install NodeJS 8.x
+RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
+ apt-get install -y nodejs
+
+# Install Yarn
+RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
+ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
+ apt-get update && apt-get install yarn
 
 # Download PeerTube's source code.
 RUN git clone -b develop https://github.com/Chocobozzz/PeerTube /home/user/PeerTube
 WORKDIR /home/user/PeerTube
 
-# Configure the IDEs to use Janitor's source directory as workspace.
-ENV WORKSPACE /home/user/PeerTube/
-
 # Install dependencies.
 RUN yarn install --pure-lockfile
 
-# Configure Janitor for PeerTube.
-COPY --chown=user:user janitor.json /home/user/
+# Configure and run PeerTube.
+COPY setup_postgres.sql /tmp/
+RUN service postgresql start \
+ && su postgres -c "psql --file=/tmp/setup_postgres.sql"
 
-# Configure and build PeerTube.
-COPY create_user.sql /tmp/
-RUN sudo service postgresql start \
- && sudo -u postgres psql --file=/tmp/create_user.sql \
- && npm run build
-
-COPY --chown=user:user supervisord.conf /tmp/supervisord-extra.conf
-RUN cat /tmp/supervisord-extra.conf | sudo tee -a /etc/supervisord.conf
+# Expose PeerTube sources as a volume
+VOLUME /home/user/PeerTube
 
 EXPOSE 3000 9000
+
+# Start PostgreSQL and Redis
+CMD service postgresql start && redis-server
diff --git a/support/docker/dev/create_user.sql b/support/docker/dev/create_user.sql
deleted file mode 100644 (file)
index c2fbcf2..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-create database peertube_dev;
-create user peertube password 'peertube';
-grant all privileges on database peertube_dev to peertube;
diff --git a/support/docker/dev/janitor.json b/support/docker/dev/janitor.json
deleted file mode 100644 (file)
index 5acdf30..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-{
-  "name": "PeerTube",
-  "description": "Federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.",
-  "icon": "https://janitor.technology/img/peertube.svg",
-  "docker": {
-    "image": "chocobozzz/peertube-dev"
-  },
-  "ports": {
-    "22": {
-      "label": "SSH",
-      "proxy": "none"
-    },
-    "3000": {
-      "label": "PeerTube web app",
-      "proxy": "https",
-      "preview": true
-    },
-    "8088": {
-      "label": "VNC",
-      "proxy": "https"
-    },
-    "8089": {
-      "label": "Cloud9",
-      "proxy": "https"
-    },
-    "8090": {
-      "label": "Theia",
-      "proxy": "https"
-    },
-    "9000": {
-      "label": "PeerTube API",
-      "proxy": "https"
-    }
-  },
-  "scripts": {
-    "Start PeerTube": "npm run dev",
-    "Build PeerTube": "npm run build",
-    "Run tests": "npm test",
-    "Update source code": "git pull --rebase origin",
-    "Send to code review": "hub pull-request"
-  }
-}
diff --git a/support/docker/dev/setup_postgres.sql b/support/docker/dev/setup_postgres.sql
new file mode 100644 (file)
index 0000000..0937f9d
--- /dev/null
@@ -0,0 +1,6 @@
+create database peertube_dev;
+create user peertube password 'peertube';
+grant all privileges on database peertube_dev to peertube;
+\c peertube_dev
+CREATE EXTENSION pg_trgm;
+CREATE EXTENSION unaccent;
diff --git a/support/docker/dev/supervisord.conf b/support/docker/dev/supervisord.conf
deleted file mode 100644 (file)
index b2e1682..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[program:postgresql]
-user = user
-command = sudo -u postgres /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf
diff --git a/support/docker/dev/usage.md b/support/docker/dev/usage.md
new file mode 100644 (file)
index 0000000..319d7db
--- /dev/null
@@ -0,0 +1,20 @@
+### Usage
+1. Build the image:
+       ```
+       docker build -t my_peertube_dev .
+       ```
+1. Start the container:
+       ```
+       docker run -d -i -p 3000:3000 -p 9000:9000 --name peertube my_peertube_dev
+       ```
+       This will create a new Docker volume containing PeerTube sources.
+
+1. Start PeerTube inside the container:
+       ```
+       docker exec -it peertube npm run dev
+       ```
+1. In another window, find the path to the Docker volume
+       ```
+       docker inspect peertube | less +/Mounts
+       ```
+       You can now make changes to the files. They should be automatically recompiled.
diff --git a/support/docker/janitor/Dockerfile b/support/docker/janitor/Dockerfile
new file mode 100644 (file)
index 0000000..2b4f2b2
--- /dev/null
@@ -0,0 +1,32 @@
+FROM janitortechnology/ubuntu-dev
+
+# Install PeerTube's dependencies.
+# Packages are from https://github.com/Chocobozzz/PeerTube#dependencies
+RUN sudo apt-get update -q && sudo apt-get install -qy \
+ ffmpeg \
+ postgresql \
+ openssl
+
+# Download PeerTube's source code.
+RUN git clone -b develop https://github.com/Chocobozzz/PeerTube /home/user/PeerTube
+WORKDIR /home/user/PeerTube
+
+# Configure the IDEs to use Janitor's source directory as workspace.
+ENV WORKSPACE /home/user/PeerTube/
+
+# Install dependencies.
+RUN yarn install --pure-lockfile
+
+# Configure Janitor for PeerTube.
+COPY --chown=user:user janitor.json /home/user/
+
+# Configure and build PeerTube.
+COPY create_user.sql /tmp/
+RUN sudo service postgresql start \
+ && sudo -u postgres psql --file=/tmp/create_user.sql \
+ && npm run build
+
+COPY --chown=user:user supervisord.conf /tmp/supervisord-extra.conf
+RUN cat /tmp/supervisord-extra.conf | sudo tee -a /etc/supervisord.conf
+
+EXPOSE 3000 9000
diff --git a/support/docker/janitor/create_user.sql b/support/docker/janitor/create_user.sql
new file mode 100644 (file)
index 0000000..c2fbcf2
--- /dev/null
@@ -0,0 +1,3 @@
+create database peertube_dev;
+create user peertube password 'peertube';
+grant all privileges on database peertube_dev to peertube;
diff --git a/support/docker/janitor/janitor.json b/support/docker/janitor/janitor.json
new file mode 100644 (file)
index 0000000..5acdf30
--- /dev/null
@@ -0,0 +1,42 @@
+{
+  "name": "PeerTube",
+  "description": "Federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.",
+  "icon": "https://janitor.technology/img/peertube.svg",
+  "docker": {
+    "image": "chocobozzz/peertube-dev"
+  },
+  "ports": {
+    "22": {
+      "label": "SSH",
+      "proxy": "none"
+    },
+    "3000": {
+      "label": "PeerTube web app",
+      "proxy": "https",
+      "preview": true
+    },
+    "8088": {
+      "label": "VNC",
+      "proxy": "https"
+    },
+    "8089": {
+      "label": "Cloud9",
+      "proxy": "https"
+    },
+    "8090": {
+      "label": "Theia",
+      "proxy": "https"
+    },
+    "9000": {
+      "label": "PeerTube API",
+      "proxy": "https"
+    }
+  },
+  "scripts": {
+    "Start PeerTube": "npm run dev",
+    "Build PeerTube": "npm run build",
+    "Run tests": "npm test",
+    "Update source code": "git pull --rebase origin",
+    "Send to code review": "hub pull-request"
+  }
+}
diff --git a/support/docker/janitor/supervisord.conf b/support/docker/janitor/supervisord.conf
new file mode 100644 (file)
index 0000000..b2e1682
--- /dev/null
@@ -0,0 +1,3 @@
+[program:postgresql]
+user = user
+command = sudo -u postgres /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf