Browse Source

Add a docker dev setup (#3)

Michael Weimann 5 months ago
parent
commit
47dbbc76a8
9 changed files with 235 additions and 2 deletions
  1. 3
    0
      .gitignore
  2. 26
    0
      Dockerfile
  3. 46
    2
      README.md
  4. 32
    0
      config.cfg.docker
  5. 32
    0
      docker-cmd.sh
  6. 12
    0
      docker-compose.yml
  7. 53
    0
      docker-setup.sh
  8. 0
    0
      fsfe.org/.gitkeep
  9. 31
    0
      less-watch.sh

+ 3
- 0
.gitignore View File

@@ -1,6 +1,9 @@
1 1
 config.cfg
2 2
 lighttpd-fsfe.conf
3 3
 pywebserver-fsfe.log
4
+fsfe.org
5
+fsfe-website
6
+
4 7
 lighttpd-fsfe*.log
5 8
 
6 9
 # ignore everything in fsfe.org/ and status/ but keep the folders

+ 26
- 0
Dockerfile View File

@@ -0,0 +1,26 @@
1
+FROM alpine:3.9
2
+
3
+RUN apk add --no-cache \
4
+    bash \
5
+    bash-completion \
6
+    coreutils \
7
+    diffutils \
8
+    findutils \
9
+    inotify-tools \
10
+    libxml2-utils \
11
+    libxslt \
12
+    make \
13
+    nodejs \
14
+    nodejs-npm \
15
+    procps \
16
+    python3 \
17
+    rsync
18
+
19
+RUN npm install -g less
20
+
21
+RUN mkdir -p /fsfe-local-build/fsfe.org
22
+
23
+EXPOSE 8000
24
+
25
+CMD sh /fsfe-local-build/docker-cmd.sh
26
+

+ 46
- 2
README.md View File

@@ -1,5 +1,49 @@
1
-# FSFE Local Build
1
+# FSFE Website Local Build
2 2
 
3
-This is a collection of scripts and configuration files necessary to build fsfe.org websites locally. 
3
+This is a collection of scripts, tools and configuration files necessary to build fsfe.org websites locally. 
4 4
 
5 5
 Full instructions can be found in FSFE's wiki: https://wiki.fsfe.org/TechDocs/Mainpage/BuildLocally
6
+
7
+## Docker based development environment
8
+
9
+For convenience local development you may want to use the docker contaienr provided by this repo.
10
+
11
+The container contains everything you need to work on the website including serving a preview, building the static pages and the CSS files.
12
+
13
+### Requirements
14
+
15
+* Docker https://docs.docker.com/install/
16
+* Docker Compose https://docs.docker.com/compose/install/
17
+* Patience (for the website build)
18
+
19
+### Website Dev Instructions
20
+
21
+#### Initial set up
22
+
23
+Just run the following command for the initial setup:
24
+
25
+```
26
+./docker-setup.sh
27
+```
28
+
29
+⚠ The command may run some hours, since it does the initial full build of the website.
30
+
31
+#### Development
32
+
33
+Spin up the container (⚠ takes some minutes):
34
+
35
+    docker-compose up
36
+
37
+The website should now be available on your machine under http://127.0.0.1:8000/.
38
+
39
+Build a single page after changes (e.g. `index.de.xhtml`):
40
+
41
+```
42
+docker exec \
43
+    --workdir /fsfe-local-build/fsfe.org \
44
+    fsfe-local-build \
45
+    bash ../fsfe-preview.sh ../fsfe-website/index.de.xhtml
46
+```
47
+
48
+Style modifications in `fsfe-website/look` trigger a re build of the styles.
49
+After modifications a page reload shoud show the changes.

+ 32
- 0
config.cfg.docker View File

@@ -0,0 +1,32 @@
1
+### BUILD DIRECTORIES ###
2
+
3
+# Cloned Git directory (repository with XHTML source files)
4
+LOC_trunk=/fsfe-local-build/fsfe-website
5
+
6
+# Directory in which the result of the build process (html files) will be saved
7
+LOC_out=/fsfe-local-build/fsfe.org
8
+
9
+
10
+### LOCAL WEBSERVER ###
11
+
12
+# Choose your local webserver. 
13
+# Default is "python" which is python3's built-in http.server module (SimpleHTTP) that is available on most distributions
14
+# Use "lighttpd" if you want to use the Lighttpd webserver. This has to be configured manually (see guide)
15
+HTTPD=lighttpd
16
+
17
+
18
+### ADVANCED ###
19
+
20
+# Directory of the secondary Git directory with which you made a first full build. 
21
+# Avoids having some generated files in your clean trunk. 
22
+# Default: Leave empty if you just want to use one Git source directory (recommended)
23
+LOC_trunk_dev=
24
+
25
+# Choose on which port the webserver runs. This has no effect for "lighttpd". 
26
+HTTPD_port=5080
27
+
28
+# If you use other webservers like "lighttpd", this is the path to its config file 
29
+# Default: points to a lighttpd config file in the same directory as the script
30
+# Has no effect if you use the "python" webserver
31
+HTTPD_conf=$ROOT/lighttpd-fsfe.conf
32
+

+ 32
- 0
docker-cmd.sh View File

@@ -0,0 +1,32 @@
1
+#!/bin/bash
2
+########################################################################
3
+#  Copyright (C) 2019 Michael Weimann <mweimann@fsfe.org>
4
+########################################################################
5
+#  
6
+#  This program is free software: you can redistribute it and/or modify
7
+#  it under the terms of the GNU General Public License as published by
8
+#  the Free Software Foundation, either version 3 of the License, or
9
+#  (at your option) any later version.
10
+#  
11
+#  This program is distributed in the hope that it will be useful,
12
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+#  GNU General Public License for more details.
15
+#  
16
+#  You should have received a copy of the GNU General Public License
17
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+#  
19
+########################################################################
20
+#  
21
+#  This script is executed in docker CMD.
22
+#  
23
+#######################################################################
24
+
25
+# Set up the less watcher
26
+cd /fsfe-local-build
27
+sh less-watch.sh &
28
+
29
+# Run the preview server
30
+cd /fsfe-local-build/fsfe.org
31
+python3 -m http.server
32
+

+ 12
- 0
docker-compose.yml View File

@@ -0,0 +1,12 @@
1
+version: '3'
2
+
3
+services:
4
+  fsfe-local-build:
5
+    build: .
6
+    image: fsfe/local-build:1.0
7
+    container_name: fsfe-local-build
8
+    ports:
9
+      - 8000:8000
10
+    volumes:
11
+      - .:/fsfe-local-build
12
+

+ 53
- 0
docker-setup.sh View File

@@ -0,0 +1,53 @@
1
+#!/bin/bash
2
+########################################################################
3
+#  Copyright (C) 2019 Michael Weimann <mweimann@fsfe.org>
4
+########################################################################
5
+#  
6
+#  This program is free software: you can redistribute it and/or modify
7
+#  it under the terms of the GNU General Public License as published by
8
+#  the Free Software Foundation, either version 3 of the License, or
9
+#  (at your option) any later version.
10
+#  
11
+#  This program is distributed in the hope that it will be useful,
12
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+#  GNU General Public License for more details.
15
+#  
16
+#  You should have received a copy of the GNU General Public License
17
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+#  
19
+########################################################################
20
+#  
21
+#  This script runs the docker dev setup.
22
+#  
23
+#######################################################################
24
+
25
+echo -e "\e[96m→ Cloning the website repo\e[0m"
26
+git clone git@git.fsfe.org:FSFE/fsfe-website.git
27
+echo ""
28
+
29
+echo -e "\e[96m→ Setting up the config file\e[0m"
30
+cp config.cfg.docker config.cfg
31
+echo ""
32
+
33
+echo -e "\e[96m→ Linking the look directory\e[0m"
34
+ln -s ../fsfe-website/look fsfe.org/look
35
+echo ""
36
+
37
+echo -e "\e[96m→ Starting the container\e[0m"
38
+docker-compose up --build -d
39
+echo ""
40
+
41
+echo -e "\e[96m→ Initial full build\e[0m"
42
+echo -e "\e[33m⚠ This may take some hours\e[0m"
43
+docker exec fsfe-local-build \
44
+ bash /fsfe-local-build/fsfe-website/build/build_main.sh \
45
+ build_into /fsfe-local-build/fsfe.org/ \
46
+ --statusdir /fsfe-local-build/status/ \
47
+ || true
48
+echo ""
49
+
50
+echo -e "\e[96m→ Stopping the container\e[0m"
51
+docker-compose stop
52
+echo ""
53
+

+ 0
- 0
fsfe.org/.gitkeep View File


+ 31
- 0
less-watch.sh View File

@@ -0,0 +1,31 @@
1
+#!/bin/bash
2
+########################################################################
3
+#  Copyright (C) 2019 Michael Weimann <mweimann@fsfe.org>
4
+########################################################################
5
+#  
6
+#  This program is free software: you can redistribute it and/or modify
7
+#  it under the terms of the GNU General Public License as published by
8
+#  the Free Software Foundation, either version 3 of the License, or
9
+#  (at your option) any later version.
10
+#  
11
+#  This program is distributed in the hope that it will be useful,
12
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+#  GNU General Public License for more details.
15
+#  
16
+#  You should have received a copy of the GNU General Public License
17
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+#  
19
+########################################################################
20
+#  
21
+#  This script sets up a watcher that re-compiles the fsfe website
22
+#  styles on changes.
23
+#  
24
+#######################################################################
25
+
26
+while inotifywait \
27
+    -r -e close_write -e create -e moved_to \
28
+    --exclude '\.(swx|swp|min\.css)' fsfe-website/look; do
29
+    lessc -x fsfe-website/look/fsfe.less fsfe-website/look/fsfe.min.css;
30
+done
31
+

Loading…
Cancel
Save