Ver Fonte

Scripted bootstrapping process

arianagiroux há 1 mês atrás
commit
c627ea5c95
7 ficheiros alterados com 87 adições e 0 exclusões
  1. 4 0
      .gitignore
  2. 1 0
      Readme.md
  3. 17 0
      bootstrap/dockerfile
  4. 15 0
      bootstrap/start.sh
  5. 19 0
      init.sh
  6. 11 0
      production/docker-compose.yml
  7. 20 0
      production/dockerfile

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.DS_Store
+.undodir
+bootstrap/data
+writefreely*.tar*

+ 1 - 0
Readme.md

@@ -0,0 +1 @@
+1. docker build -t writefreely .

+ 17 - 0
bootstrap/dockerfile

@@ -0,0 +1,17 @@
+FROM alpine
+# DEFAULTS PREP
+VOLUME /data
+VOLUME /app
+EXPOSE 8080/tcp
+
+# PATH PREP
+RUN mkdir -p /app/writefreely
+WORKDIR /app/writefreely
+RUN mkdir /data
+
+# DATA PREP
+ADD writefreely_0.16.0_linux_arm64.tar /app/
+COPY start.sh /app/writefreely/start.sh
+RUN chmod +x /app/writefreely/start.sh
+
+CMD ./start.sh

+ 15 - 0
bootstrap/start.sh

@@ -0,0 +1,15 @@
+#! /bin/sh
+
+# get current state of cwd
+files=$(ls)
+
+# run writefreely init commands
+./writefreely config start || exit 1
+
+# copy any resulting files to the data directory
+for file in $(ls); do
+	if ! echo $files | grep -q $file; then
+		cp $file /data/
+		echo "Copied $file to /data"
+	fi
+done

+ 19 - 0
init.sh

@@ -0,0 +1,19 @@
+#! /bin/sh
+
+echo "Running writefreely bootstrap"
+cp production/writefreely*.tar* bootstrap/
+
+pushd bootstrap
+docker build -t writefreely-bootstrap .
+docker run -it --rm -v ./data:/data writefreely-bootstrap
+if [ $? -ne 0 ]; then
+	exit 1
+fi
+docker image rm writefreely-bootstrap # cleanup
+rm writefreely*.tar* # cleanup
+
+popd
+cp bootstrap/data/* production/
+
+pushd production
+docker compose build

+ 11 - 0
production/docker-compose.yml

@@ -0,0 +1,11 @@
+services:
+  writefreely:
+    build:
+      context: .
+    volumes:
+      - writefreely_data:/app/writefreely
+    ports:
+      - 8088:8080
+
+volumes:
+  writefreely_data:

+ 20 - 0
production/dockerfile

@@ -0,0 +1,20 @@
+FROM alpine
+# DEFAULTS PREP
+VOLUME /data
+VOLUME /app
+EXPOSE 8080/tcp
+
+# PATH PREP
+RUN mkdir -p /app/writefreely
+WORKDIR /app/writefreely
+RUN mkdir /data
+
+# DATA PREP
+ADD writefreely_0.16.0_linux_arm64.tar /app/
+COPY ./config.ini /app/writefreely/config.ini
+COPY ./writefreely.db /app/writefreely/writefreely.db
+
+# GENERATE KEYS
+RUN ./writefreely keys generate
+
+CMD ./writefreely