← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~tushar5526/launchpad:devsetup-using-docker-for-lp into launchpad:master

 

Tushar Gupta has proposed merging ~tushar5526/launchpad:devsetup-using-docker-for-lp into launchpad:master.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~tushar5526/launchpad/+git/launchpad/+merge/472749
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~tushar5526/launchpad:devsetup-using-docker-for-lp into launchpad:master.
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..4fd8243
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,8 @@
+services:
+  launchpad:
+    build:
+      context: .
+      dockerfile: docker/Dockerfile
+    ports:
+      - 127.0.0.88:80:80
+      - 127.0.0.88:443:443
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..fc80a7e
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,34 @@
+FROM ubuntu:20.04
+
+ENV TZ=Asia/Kolkata \
+    DEBIAN_FRONTEND=noninteractive
+
+
+
+RUN apt-get update 
+RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata. 
+RUN apt-get install -y curl sudo lsb-release gnupg2 wget git
+RUN mkdir /srv/launchpad
+
+COPY utilities/rocketfuel-setup /usr/local/bin/rocketfuel-setup
+COPY utilities/rocketfuel-get /usr/local/bin/rocketfuel-get
+RUN chmod a+x /usr/local/bin/rocketfuel-setup
+RUN chmod a+x /usr/local/bin/rocketfuel-get
+
+COPY . /root/launchpad/launchpad
+RUN git clone https://git.launchpad.net/lp-source-dependencies /root/launchpad/lp-sourcedeps/download-cache --depth=1
+
+RUN rocketfuel-setup --no-workspace --assume-yes --lpusername root 
+
+COPY docker/rocketfuel-env.sample /root/.rocketfuel-env.sh
+
+RUN rocketfuel-get
+
+# All in one line because we need Postgres to be running
+RUN /root/launchpad/launchpad/utilities/launchpad-database-setup root && make schema
+RUN make LISTEN_ADDRESS="*" install
+
+COPY docker/run.sh /root/launchpad/launchpad
+RUN chmod +x /root/launchpad/launchpad/run.sh
+
+ENTRYPOINT ["/root/launchpad/launchpad/run.sh"]
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..33ade8b
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,16 @@
+Steps towards making Launchpad Dev Environment process easier. 
+
+# Steps to run Launchpad locally
+
+1. Make sure ports 80, 443 are free (usually occupied by nginx or any other webserver on your system).
+2. Run `bash docker/bootstrap-setup.sh` which creates hosts entry for the dev environment.
+3. From the Launchpad root folder, run `docker compose up -d` to bring up an instance of Launchpad.
+
+# TODOs
+
+1. Create a separate service which only handles setup of database. We don't need to re-create database on each code change. 
+2. Investigate linking Launchpad with the database running on a different container. 
+3. Check if its possible to mount Launchpad's code from the host workspace into container, so that changes are reflected on each restart. This is more of a good to have for Developer experience, because majority of the time goes in setting up Database and re-building Launchpad on every code change still seems acceptable. 
+4. The Launchpad setup documentation here - https://documentation.ubuntu.com/launchpad/en/latest/how-to/running/#css-watch mentions setting `css_watch` for FE changes that needs to investigated. 
+
+
diff --git a/docker/bootstrap-setup.sh b/docker/bootstrap-setup.sh
new file mode 100755
index 0000000..cd1f297
--- /dev/null
+++ b/docker/bootstrap-setup.sh
@@ -0,0 +1,41 @@
+
+dev_host() {
+  if ! grep -q "^127.0.0.88.* ${hostname}" /etc/hosts; then
+    sudo sed -i "s/^127.0.0.88.*$/&\ ${hostname}/" /etc/hosts
+    echo "${hostname} added to /etc/hosts"
+  fi
+  }
+
+if ! grep -q "^127.0.0.88" /etc/hosts; then
+  echo "Adding development hosts on local machine"
+  echo "
+# Launchpad virtual domains. This should be on one line.
+127.0.0.88      launchpad.test
+" | sudo tee -a /etc/hosts > /dev/null
+  echo "launchpad.test added to /etc/hosts"
+fi
+
+hostnames=$(cat <<EOF
+    answers.launchpad.test
+    archive.launchpad.test
+    api.launchpad.test
+    bazaar.launchpad.test
+    bazaar-internal.launchpad.test
+    blueprints.launchpad.test
+    bugs.launchpad.test
+    code.launchpad.test
+    feeds.launchpad.test
+    keyserver.launchpad.test
+    lists.launchpad.test
+    ppa.launchpad.test
+    private-ppa.launchpad.test
+    testopenid.test
+    translations.launchpad.test
+    xmlrpc-private.launchpad.test
+    xmlrpc.launchpad.test
+EOF
+    )
+
+for hostname in $hostnames; do
+  dev_host;
+done
\ No newline at end of file
diff --git a/docker/rocketfuel-env.sample b/docker/rocketfuel-env.sample
new file mode 100644
index 0000000..5a6b12f
--- /dev/null
+++ b/docker/rocketfuel-env.sample
@@ -0,0 +1,21 @@
+# Common environment variables for the rocketfuel-* scripts.
+#
+# The ones you can set are:
+#
+# LP_PROJECT_ROOT - The root directory of all your Launchpad stuff.  Your
+#                   Launchpad repository will live in a child directory
+#                   of this directory.
+# LP_TRUNK_NAME   - The directory name (not path!) to your rocketfuel trunk
+#                   mirror directory.  This is relative to your
+#                   LP_PROJECT_ROOT.
+# LP_SOURCEDEPS_DIR - The name of the directory (not path!) where your
+#                   trunk sourcecode will be placed.  This is relative to your
+#                   LP_PROJECT_ROOT and should /not/ have the 'sourcecode'
+#                   path appended to it, since this is automatically added by
+#                   the scripts.
+
+LP_PROJECT_ROOT=${LP_PROJECT_ROOT:=~/launchpad}
+LP_TRUNK_NAME=${LP_TRUNK_NAME:=launchpad}
+LP_TRUNK_PATH=$LP_PROJECT_ROOT/$LP_TRUNK_NAME
+
+LP_SOURCEDEPS_DIR=${LP_SOURCEDEPS_DIR:=lp-sourcedeps}
\ No newline at end of file
diff --git a/docker/run.sh b/docker/run.sh
new file mode 100644
index 0000000..2bde110
--- /dev/null
+++ b/docker/run.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+service postgresql start
+service apache2 start
+make run
\ No newline at end of file