mirror of
https://github.com/jrasanen/writefreely-docker.git
synced 2025-07-07 06:07:52 +03:00
Compare commits
No commits in common. "main" and "v1.1.1" have entirely different histories.
10 changed files with 165 additions and 491 deletions
|
@ -1,3 +1 @@
|
||||||
data
|
data
|
||||||
db-data
|
|
||||||
.env
|
|
||||||
|
|
38
.env.mariadb
38
.env.mariadb
|
@ -1,38 +0,0 @@
|
||||||
|
|
||||||
# General Configuration
|
|
||||||
WRITEFREELY_BIND_PORT=8080
|
|
||||||
WRITEFREELY_BIND_HOST=0.0.0.0
|
|
||||||
WRITEFREELY_SITE_NAME="My Blog"
|
|
||||||
WRITEFREELY_SITE_DESCRIPTION="My fancy blog"
|
|
||||||
|
|
||||||
# Database Configuration
|
|
||||||
MARIADB_USER=writefreely
|
|
||||||
MARIADB_PASSWORD=changeme
|
|
||||||
MARIADB_DATABASE=writefreely
|
|
||||||
MARIADB_ROOT_PASSWORD=changeme
|
|
||||||
|
|
||||||
WRITEFREELY_DATABASE_DATABASE=mysql
|
|
||||||
WRITEFREELY_DATABASE_USERNAME=${MARIADB_USER}
|
|
||||||
WRITEFREELY_DATABASE_PASSWORD=${MARIADB_PASSWORD}
|
|
||||||
WRITEFREELY_DATABASE_NAME=${MARIADB_DATABASE}
|
|
||||||
WRITEFREELY_DATABASE_HOST=writefreely-db
|
|
||||||
WRITEFREELY_DATABASE_PORT=3306
|
|
||||||
|
|
||||||
|
|
||||||
# Application Settings
|
|
||||||
WRITEFREELY_HOST=
|
|
||||||
WRITEFREELY_SINGLE_USER=true
|
|
||||||
WRITEFREELY_OPEN_REGISTRATION=false
|
|
||||||
WRITEFREELY_MIN_USERNAME_LEN=4
|
|
||||||
WRITEFREELY_MAX_BLOG=4
|
|
||||||
WRITEFREELY_FEDERATION=true
|
|
||||||
WRITEFREELY_PUBLIC_STATS=true
|
|
||||||
WRITEFREELY_PRIVATE=false
|
|
||||||
WRITEFREELY_LOCAL_TIMELINE=true
|
|
||||||
WRITEFREELY_USER_INVITES=
|
|
||||||
|
|
||||||
# Writefreely Users
|
|
||||||
WRITEFREELY_ADMIN_USER=admin
|
|
||||||
WRITEFREELY_ADMIN_PASSWORD=changeme
|
|
||||||
WRITEFREELY_WRITER_USER=
|
|
||||||
WRITEFREELY_WRITER_PASSWORD=
|
|
31
.env.sqlite
31
.env.sqlite
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
# General Configuration
|
|
||||||
WRITEFREELY_BIND_PORT=8080
|
|
||||||
WRITEFREELY_BIND_HOST=0.0.0.0
|
|
||||||
WRITEFREELY_SITE_NAME="My Blog"
|
|
||||||
WRITEFREELY_SITE_DESCRIPTION="My fancy blog"
|
|
||||||
|
|
||||||
# Database Configuration
|
|
||||||
WRITEFREELY_DATABASE_DATABASE=sqlite3
|
|
||||||
WRITEFREELY_SQLITE_FILENAME=./writefreely.db
|
|
||||||
WRITEFREELY_DATABASE_USERNAME=writefreely
|
|
||||||
WRITEFREELY_DATABASE_PASSWORD=changeme
|
|
||||||
WRITEFREELY_DATABASE_NAME=writefreely
|
|
||||||
|
|
||||||
# Application Settings
|
|
||||||
WRITEFREELY_HOST=
|
|
||||||
WRITEFREELY_SINGLE_USER=true
|
|
||||||
WRITEFREELY_OPEN_REGISTRATION=false
|
|
||||||
WRITEFREELY_MIN_USERNAME_LEN=4
|
|
||||||
WRITEFREELY_MAX_BLOG=4
|
|
||||||
WRITEFREELY_FEDERATION=true
|
|
||||||
WRITEFREELY_PUBLIC_STATS=true
|
|
||||||
WRITEFREELY_PRIVATE=false
|
|
||||||
WRITEFREELY_LOCAL_TIMELINE=true
|
|
||||||
WRITEFREELY_USER_INVITES=
|
|
||||||
|
|
||||||
# Writefreely Users
|
|
||||||
WRITEFREELY_ADMIN_USER=admin
|
|
||||||
WRITEFREELY_ADMIN_PASSWORD=changeme
|
|
||||||
WRITEFREELY_WRITER_USER=
|
|
||||||
WRITEFREELY_WRITER_PASSWORD=
|
|
99
.github/workflows/docker-publish.yml
vendored
99
.github/workflows/docker-publish.yml
vendored
|
@ -1,63 +1,88 @@
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|
||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
tags: [ 'v*.*.*' ]
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '37 1 * * *'
|
- cron: '37 1 * * *'
|
||||||
|
push:
|
||||||
concurrency:
|
branches: [ main ]
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
# Publish semver tags as releases.
|
||||||
cancel-in-progress: true
|
tags: [ 'v*.*.*' ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
WRITEFREELY_VERSION: v0.15.1
|
# Use docker.io for Docker Hub if empty
|
||||||
DOCKERHUB_REPO: jrasanen/writefreely
|
REGISTRY: ghcr.io
|
||||||
|
# github.repository as <account>/<repo>
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
# This is used to complete the identity challenge
|
||||||
|
# with sigstore/fulcio when running outside of PRs.
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||||
|
- name: Setup Docker buildx
|
||||||
|
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
|
||||||
|
|
||||||
|
# Login against a Docker registry except on PR
|
||||||
|
# https://github.com/docker/login-action
|
||||||
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
# Extract metadata (tags, labels) for Docker
|
||||||
uses: docker/setup-buildx-action@v3
|
# https://github.com/docker/metadata-action
|
||||||
|
- name: Extract Docker metadata
|
||||||
- uses: actions/cache@v4
|
id: meta
|
||||||
|
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||||
with:
|
with:
|
||||||
path: |
|
images: |
|
||||||
~/.cache/go-build
|
jrasanen/writefreely
|
||||||
~/go/pkg/mod
|
ghcr.io/${{ github.repository }}
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
|
|
||||||
- name: Build and Push
|
|
||||||
uses: docker/build-push-action@v5
|
# Build and push Docker image with Buildx (don't push on PR)
|
||||||
|
# https://github.com/docker/build-push-action
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: build-and-push
|
||||||
|
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
push: true
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Build and push Docker images
|
||||||
|
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
build-args: |
|
|
||||||
WRITEFREELY_VERSION=${{ env.WRITEFREELY_VERSION }}
|
|
||||||
tags: |
|
|
||||||
${{ env.DOCKERHUB_REPO }}:${{ env.WRITEFREELY_VERSION }}
|
|
||||||
${{ env.DOCKERHUB_REPO }}:latest
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1 @@
|
||||||
/data/
|
/data/
|
||||||
/db-data/
|
|
||||||
/.env
|
|
||||||
|
|
49
Dockerfile
49
Dockerfile
|
@ -1,30 +1,38 @@
|
||||||
ARG GOLANG_VERSION=1.22
|
## Writefreely Docker image
|
||||||
|
## Copyright (C) 2019, 2020 Gergely Nagy
|
||||||
|
##
|
||||||
|
## This program is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
ARG GOLANG_VERSION=1.21
|
||||||
|
|
||||||
# Build image
|
# Build image
|
||||||
FROM golang:${GOLANG_VERSION}-alpine as build
|
FROM golang:${GOLANG_VERSION}-alpine as build
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/writefreely/writefreely"
|
ARG WRITEFREELY_VERSION=v0.14.0
|
||||||
LABEL org.opencontainers.image.description="WriteFreely is a clean, minimalist publishing platform made for writers. Start a blog, share knowledge within your organization, or build a community around the shared act of writing."
|
ARG WRITEFREELY_FORK=writeas/writefreely
|
||||||
|
|
||||||
ARG WRITEFREELY_VERSION=v0.15.1
|
RUN apk add --update nodejs npm make g++ git sqlite-dev
|
||||||
ARG WRITEFREELY_FORK=writefreely/writefreely
|
|
||||||
|
|
||||||
RUN apk -U upgrade \
|
|
||||||
&& apk add --no-cache nodejs npm make g++ git sqlite-dev \
|
|
||||||
&& npm install -g less less-plugin-clean-css \
|
|
||||||
&& mkdir -p /go/src/github.com/writefreely/writefreely
|
|
||||||
RUN npm install -g less less-plugin-clean-css
|
RUN npm install -g less less-plugin-clean-css
|
||||||
|
RUN go get -u github.com/jteeuwen/go-bindata/...
|
||||||
|
|
||||||
RUN mkdir -p /go/src/github.com/${WRITEFREELY_FORK}
|
RUN mkdir -p /go/src/github.com/${WRITEFREELY_FORK}
|
||||||
RUN git clone https://github.com/${WRITEFREELY_FORK}.git /go/src/github.com/${WRITEFREELY_FORK} -b ${WRITEFREELY_VERSION}
|
RUN git clone https://github.com/${WRITEFREELY_FORK}.git /go/src/github.com/${WRITEFREELY_FORK} -b ${WRITEFREELY_VERSION}
|
||||||
WORKDIR /go/src/github.com/${WRITEFREELY_FORK}
|
WORKDIR /go/src/github.com/${WRITEFREELY_FORK}
|
||||||
|
|
||||||
ENV GO111MODULE=on
|
ENV GO111MODULE=on
|
||||||
ENV NODE_OPTIONS=--openssl-legacy-provider
|
|
||||||
|
|
||||||
RUN make build \
|
RUN make build \
|
||||||
&& make ui
|
&& make ui
|
||||||
|
|
||||||
RUN mkdir /stage && \
|
RUN mkdir /stage && \
|
||||||
cp -R /go/bin \
|
cp -R /go/bin \
|
||||||
/go/src/github.com/${WRITEFREELY_FORK}/templates \
|
/go/src/github.com/${WRITEFREELY_FORK}/templates \
|
||||||
|
@ -36,15 +44,9 @@ RUN mkdir /stage && \
|
||||||
mv /stage/cmd/writefreely/writefreely /stage
|
mv /stage/cmd/writefreely/writefreely /stage
|
||||||
|
|
||||||
# Final image
|
# Final image
|
||||||
FROM alpine:3.19
|
FROM alpine:3.18
|
||||||
|
|
||||||
ARG WRITEFREELY_UID=1000
|
|
||||||
ARG WRITEFREELY_GID=1000
|
|
||||||
|
|
||||||
RUN apk -U upgrade && apk add --no-cache openssl ca-certificates
|
|
||||||
|
|
||||||
RUN addgroup -g ${WRITEFREELY_GID} -S writefreely && adduser -u ${WRITEFREELY_UID} -S -G writefreely writefreely
|
|
||||||
|
|
||||||
|
RUN apk add --no-cache openssl ca-certificates
|
||||||
COPY --from=build --chown=daemon:daemon /stage /writefreely
|
COPY --from=build --chown=daemon:daemon /stage /writefreely
|
||||||
COPY bin/writefreely-docker.sh /writefreely/
|
COPY bin/writefreely-docker.sh /writefreely/
|
||||||
|
|
||||||
|
@ -52,9 +54,4 @@ WORKDIR /writefreely
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
RUN chown -R writefreely:writefreely /writefreely
|
|
||||||
|
|
||||||
USER writefreely
|
|
||||||
|
|
||||||
ENTRYPOINT ["/writefreely/writefreely-docker.sh"]
|
ENTRYPOINT ["/writefreely/writefreely-docker.sh"]
|
||||||
|
|
||||||
|
|
169
README.md
169
README.md
|
@ -1,143 +1,58 @@
|
||||||
# WriteFreely Docker Build
|
# writefreely-docker
|
||||||
|
|
||||||
This project builds a Docker image for [WriteFreely](https://github.com/writefreely/writefreely), a minimalist, privacy-focused, and federated blogging platform. The image is uses on Alpine Linux.
|
[](https://ci.madhouse-project.org/algernon/writefreely-docker)
|
||||||
|
[](https://hub.docker.com/r/algernon/writefreely)
|
||||||
|
[](https://git.madhouse-project.org/algernon/writefreely-docker)
|
||||||
|
|
||||||
|
This is a [Docker][docker] image for [WriteFreely][writefreely], set up in a way
|
||||||
|
that makes it easier to deploy it in production, including the initial setup step.
|
||||||
|
|
||||||
|
[docker]: https://www.docker.com/
|
||||||
|
[writefreely]: https://github.com/writeas/writefreely
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The image is set up to use SQLite for the database, it does not support MySQL
|
||||||
|
out of the box - but you can always provide your own `config.ini`. The config
|
||||||
|
file, the database, and the generated keys are all stored on the single volume
|
||||||
|
the image uses, mounted on `/data`.
|
||||||
|
|
||||||
|
The primary purpose of the image is to provide a single-step setup and upgrade
|
||||||
|
experience, where the initial setup and any upgrades are handled by the image
|
||||||
|
itself. As such, the image will create a default `config.ini` unless one already
|
||||||
|
exists, with reasonable defaults. It will also run database migrations, and save
|
||||||
|
a backup before doing so (which it will delete, if no migrations were
|
||||||
|
necessary).
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
To get started, the easiest way to test it out is running the following command:
|
To get started, the easiest way to test it out is running the following command:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker run -p 8080:8080 -it --rm -v /some/path/to/data:/data \
|
docker run -p 8080:8080 -it --rm -v /some/path/to/data:/data \
|
||||||
jrasanen/writefreely
|
algernon/writefreely
|
||||||
```
|
```
|
||||||
|
|
||||||
Then point your browser to http://localhost:8080, and you should see WriteFreely up and running.
|
Then point your browser to `http://localhost:8080`, and you should see
|
||||||
|
WriteFreely up and running.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
The image will perform an initial setup, unless the supplied volume already contains a config.ini. Settings can be tweaked via environment variables, of which you can find a list below. Do note that these environment variables are only used for the initial setup as of this writing! If a configuration file already exists, the environment variables will be blissfully ignored.
|
The image will perform an initial setup, unless the supplied volume already
|
||||||
|
contains a `config.ini`. Settings can be tweaked via environment variables, of
|
||||||
|
which you can find a list below. Do note that these environment variables are
|
||||||
|
*only* used for the initial setup as of this writing! If a configuration file
|
||||||
|
already exists, the environment variables will be blissfully ignored.
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
The following variables will be used to construct the `config.ini` on first start. After it has been configured, you can edit it on the volume.
|
- `WRITEFREELY_BIND_HOST` and `WRITEFREELY_BIND_PORT` determine the host and port WriteFreely will bind to. Defaults to `0.0.0.0` and `8080`, respectively.
|
||||||
|
- `WRITEFREELY_SITE_NAME` is the site title one wants. Defaults to "A Writefreely blog".
|
||||||
|
- `WRITEFREELY_SINGLE_USER`, `WRITEFREELY_OPEN_REGISTRATION`,
|
||||||
|
`WRITEFREELY_MIN_USERNAME_LEN`, `WRITEFREELY_MAX_BLOG`,
|
||||||
|
`WRITEFREELY_FEDERATION`, `WRITEFREELY_PUBLIC_STATS`, `WRITEFREELY_PRIVATE`,
|
||||||
|
`WRITEFREELY_LOCAL_TIMELINE`, and `WRITEFREELY_USER_INVITES` all correspond to
|
||||||
|
the similarly named `config.ini` settings. See the [WriteFreely docs][wf:docs]
|
||||||
|
for more information about them.
|
||||||
|
|
||||||
## General Configuration
|
[wf:docs]: https://writefreely.org/docs/latest/admin/config
|
||||||
|
|
||||||
- **`WRITEFREELY_BIND_PORT`**: Specifies the port on which the WriteFreely server will listen. Defaults to `8080`.
|
|
||||||
- **`WRITEFREELY_BIND_HOST`**: Defines the host IP to bind to. Defaults to `0.0.0.0`.
|
|
||||||
- **`WRITEFREELY_SITE_NAME`**: Sets the name of your WriteFreely site. Used to identify the site in federation.
|
|
||||||
- **`WRITEFREELY_SITE_DESCRIPTION`**: Provides a short description of your site. This description may be used in federated networks.
|
|
||||||
|
|
||||||
## Database Configuration
|
|
||||||
|
|
||||||
- **`WRITEFREELY_DATABASE_DATABASE`**: Specifies the type of database used, such as `mysql` or `sqlite3`.
|
|
||||||
- **`WRITEFREELY_SQLITE_FILENAME`**: (Optional) DB filename if `sqlite3` detabase is selected. Defaults to `/data/writefreely.db`.
|
|
||||||
- **`WRITEFREELY_DATABASE_USERNAME`**: The username for the database.
|
|
||||||
- **`WRITEFREELY_DATABASE_PASSWORD`**: The password for the database.
|
|
||||||
- **`WRITEFREELY_DATABASE_NAME`**: The name of the database to connect to.
|
|
||||||
- **`WRITEFREELY_DATABASE_HOST`**: The hostname or IP address of the database server.
|
|
||||||
- **`WRITEFREELY_DATABASE_PORT`**: The port number on which the database server is running.
|
|
||||||
|
|
||||||
## Application Settings
|
|
||||||
|
|
||||||
- **`WRITEFREELY_HOST`**: The full URL where the site will be accessible.
|
|
||||||
- **`WRITEFREELY_SINGLE_USER`**: Set to `true` to run the instance as a single-user blog, otherwise `false`.
|
|
||||||
- **`WRITEFREELY_OPEN_REGISTRATION`**: Whether or not anyone can register via the landing page
|
|
||||||
- **`WRITEFREELY_MIN_USERNAME_LEN`**: The minimum length for usernames.
|
|
||||||
- **`WRITEFREELY_MAX_BLOG`**: Maximum number of blogs a single user can create under one account
|
|
||||||
- **`WRITEFREELY_FEDERATION`**: Whether or not federation via ActivityPub is enabled
|
|
||||||
- **`WRITEFREELY_PUBLIC_STATS`**: DWhether or not usage stats are made public via NodeInfo
|
|
||||||
- **`WRITEFREELY_PRIVATE`**: Set to `true` to make the site private.
|
|
||||||
- **`WRITEFREELY_LOCAL_TIMELINE`**: Whether or not the instance reader (and the Public option on blogs) is enabled
|
|
||||||
- **`WRITEFREELY_USER_INVITES`**: Who is allowed to send user invites, if anyone. A blank value disables invites for all users. Valid choices: empty, user, or admin
|
|
||||||
|
|
||||||
## Writefreely Users
|
|
||||||
|
|
||||||
- **`WRITEFREELY_ADMIN_USER`**: Administrator user name. In single user instances is editor too.
|
|
||||||
- **`WRITEFREELY_ADMIN_PASSWORD`**: Administrator password
|
|
||||||
|
|
||||||
### Volumes
|
|
||||||
|
|
||||||
* `/data`: Directory where WriteFreely stores its data, including database files and configuration.
|
|
||||||
|
|
||||||
### Using Docker Compose
|
|
||||||
|
|
||||||
You can use Docker Compose to set up WriteFreely with different database configurations. The configuration files are already included in this repository. Follow the steps below to start the services.
|
|
||||||
|
|
||||||
#### Clone the Repository
|
|
||||||
|
|
||||||
First, clone this repository:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/yourusername/writefreely-docker.git
|
|
||||||
cd writefreely-docker
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Prepare the Data Directory
|
|
||||||
|
|
||||||
Create the data directory and assign the appropriate permissions:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mkdir data
|
|
||||||
sudo chown 1000:1000 data
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Configure the Environment
|
|
||||||
|
|
||||||
Before starting the services, you need to copy the appropriate .env file and edit it to configure the environment variables, especially the passwords.
|
|
||||||
|
|
||||||
##### For MariaDB
|
|
||||||
|
|
||||||
Copy the .env.mariadb file to .env:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp .env.mariadb .env
|
|
||||||
```
|
|
||||||
|
|
||||||
##### For SQLite
|
|
||||||
|
|
||||||
Copy the .env.sqlite file to .env:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp .env.sqlite .env
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, edit the .env file to set the appropriate values for your environment:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nano .env
|
|
||||||
```
|
|
||||||
|
|
||||||
Ensure to set secure passwords and other necessary configuration options.
|
|
||||||
|
|
||||||
#### Start the Services
|
|
||||||
|
|
||||||
##### MariaDB
|
|
||||||
|
|
||||||
To use the **MariaDB** configuration, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose -f docker-compose.mariadb.yaml up
|
|
||||||
```
|
|
||||||
|
|
||||||
##### SQLite
|
|
||||||
|
|
||||||
To use the **SQLite** configuration, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose -f docker-compose.sqlite3.yaml up
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building the Image
|
|
||||||
|
|
||||||
If you want to build the image yourself, clone this repository and run the following command inside the repository's directory:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build -t yourusername/writefreely .
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace `yourusername` with your Docker Hub username or a suitable image name.
|
|
||||||
|
|
||||||
### Contributing
|
|
||||||
|
|
||||||
Contributions are welcome! Please fork this repository and submit pull requests for any enhancements or bug fixes.
|
|
||||||
|
|
|
@ -20,204 +20,61 @@ set -e
|
||||||
cd /data
|
cd /data
|
||||||
|
|
||||||
WRITEFREELY=/writefreely/writefreely
|
WRITEFREELY=/writefreely/writefreely
|
||||||
attempts=0
|
|
||||||
max_attempts=5
|
|
||||||
|
|
||||||
log() {
|
|
||||||
echo "$(date '+%Y/%m/%d %H:%M:%S') $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_url() {
|
|
||||||
URL="$1"
|
|
||||||
if echo "$URL" | grep -Eq "^https?://[a-zA-Z0-9._-]+"; then
|
|
||||||
return 0 # Success
|
|
||||||
else
|
|
||||||
return 1 # Failure
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
retry_command() {
|
|
||||||
local cmd=$1
|
|
||||||
attempts=0
|
|
||||||
until $cmd; do
|
|
||||||
attempts=$((attempts+1))
|
|
||||||
if [ $attempts -ge $max_attempts ]; then
|
|
||||||
log "Failed to execute '$cmd' after $attempts attempts."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
log "Retrying '$cmd' ($attempts/$max_attempts)..."
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize_database() {
|
|
||||||
log "Initializing database..."
|
|
||||||
if ! retry_command "${WRITEFREELY} --init-db"; then
|
|
||||||
log "Initialization of database failed. Removing config.ini."
|
|
||||||
rm ./config.ini
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
generate_keys() {
|
|
||||||
log "Generating keys..."
|
|
||||||
${WRITEFREELY} --gen-keys
|
|
||||||
}
|
|
||||||
|
|
||||||
create_admin_user() {
|
|
||||||
if [ -n "$WRITEFREELY_ADMIN_USER" ]; then
|
|
||||||
${WRITEFREELY} user create --admin ${WRITEFREELY_ADMIN_USER}:${WRITEFREELY_ADMIN_PASSWORD}
|
|
||||||
log "Created admin user ${WRITEFREELY_ADMIN_USER}"
|
|
||||||
else
|
|
||||||
log "Admin user not defined"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
create_writer_user() {
|
|
||||||
if [ -n "$WRITEFREELY_WRITER_USER" ]; then
|
|
||||||
${WRITEFREELY} user create ${WRITEFREELY_WRITER_USER}:${WRITEFREELY_WRITER_PASSWORD}
|
|
||||||
log "Created writer user ${WRITEFREELY_WRITER_USER}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_url "$WRITEFREELY_HOST" || {
|
|
||||||
log "Error: $WRITEFREELY_HOST is not a valid URL. It must start with http:// or https:// and be followed by a valid hostname."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -e ./config.ini ] && [ -e ./keys/email.aes256 ]; then
|
if [ -e ./config.ini ] && [ -e ./keys/email.aes256 ]; then
|
||||||
log "Migration required. Running migration..."
|
${WRITEFREELY} -migrate
|
||||||
${WRITEFREELY} -migrate
|
exec ${WRITEFREELY}
|
||||||
exec ${WRITEFREELY}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e ./config.ini ]; then
|
if [ -e ./config.ini ]; then
|
||||||
initialize_database
|
${WRITEFREELY} -init-db
|
||||||
generate_keys
|
${WRITEFREELY} -gen-keys
|
||||||
create_admin_user
|
exec ${WRITEFREELY}
|
||||||
create_writer_user
|
|
||||||
exec ${WRITEFREELY}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WRITEFREELY_BIND_PORT="${WRITEFREELY_BIND_PORT:-8080}"
|
WRITEFREELY_BIND_PORT="${WRITEFREELY_BIND_PORT:-8080}"
|
||||||
WRITEFREELY_BIND_HOST="${WRITEFREELY_BIND_HOST:-0.0.0.0}"
|
WRITEFREELY_BIND_HOST="${WRITEFREELY_BIND_HOST:-0.0.0.0}"
|
||||||
WRITEFREELY_SITE_NAME="${WRITEFREELY_SITE_NAME:-A Writefreely blog}"
|
WRITEFREELY_SITE_NAME="${WRITEFREELY_SITE_NAME:-A Writefreely blog}"
|
||||||
WRITEFREELY_SITE_DESCRIPTION="${WRITEFREELY_SITE_DESCRIPTION:-My Writefreely blog}"
|
|
||||||
|
|
||||||
cat >./config.ini <<EOF
|
cat >./config.ini <<EOF
|
||||||
[server]
|
[server]
|
||||||
hidden_host =
|
hidden_host =
|
||||||
port = ${WRITEFREELY_BIND_PORT}
|
port = ${WRITEFREELY_BIND_PORT}
|
||||||
bind = ${WRITEFREELY_BIND_HOST}
|
bind = ${WRITEFREELY_BIND_HOST}
|
||||||
tls_cert_path =
|
tls_cert_path =
|
||||||
tls_key_path =
|
tls_key_path =
|
||||||
autocert =
|
templates_parent_dir = /writefreely
|
||||||
templates_parent_dir = /writefreely
|
static_parent_dir = /writefreely
|
||||||
static_parent_dir = /writefreely
|
pages_parent_dir = /writefreely
|
||||||
pages_parent_dir = /writefreely
|
keys_parent_dir =
|
||||||
keys_parent_dir =
|
|
||||||
hash_seed =
|
|
||||||
gopher_port = 0
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
type = ${WRITEFREELY_DATABASE_DATABASE}
|
type = mysql
|
||||||
filename = ${WRITEFREELY_SQLITE_FILENAME:-/data/writefreely.db}
|
username = ${WRITEFREELY_DATABASE_USERNAME}
|
||||||
username = ${WRITEFREELY_DATABASE_USERNAME}
|
password = ${WRITEFREELY_DATABASE_PASSWORD}
|
||||||
password = ${WRITEFREELY_DATABASE_PASSWORD}
|
database = ${WRITEFREELY_DATABASE_NAME}
|
||||||
database = ${WRITEFREELY_DATABASE_NAME}
|
host = ${WRITEFREELY_DATABASE_HOST}
|
||||||
host = ${WRITEFREELY_DATABASE_HOST}
|
port = 3306
|
||||||
port = ${WRITEFREELY_DATABASE_PORT}
|
|
||||||
tls = false
|
|
||||||
|
|
||||||
[app]
|
[app]
|
||||||
site_name = ${WRITEFREELY_SITE_NAME}
|
site_name = ${WRITEFREELY_SITE_NAME}
|
||||||
site_description = ${WRITEFREELY_SITE_DESCRIPTION}
|
site_description =
|
||||||
host = ${WRITEFREELY_HOST:-http://${WRITEFREELY_BIND_HOST}:${WRITEFREELY_BIND_PORT}}
|
host = ${WRITEFREELY_HOST:-http://${WRITEFREELY_BIND_HOST}:${WRITEFREELY_BIND_PORT}}
|
||||||
theme = write
|
theme = write
|
||||||
editor =
|
disable_js = false
|
||||||
disable_js = false
|
webfonts = true
|
||||||
webfonts = true
|
landing =
|
||||||
landing =
|
single_user = ${WRITEFREELY_SINGLE_USER:-false}
|
||||||
simple_nav = false
|
open_registration = ${WRITEFREELY_OPEN_REGISTRATION:-false}
|
||||||
wf_modesty = false
|
min_username_len = ${WRITEFREELY_MIN_USERNAME_LEN:-3}
|
||||||
chorus = false
|
max_blogs = ${WRITEFREELY_MAX_BLOG:-1}
|
||||||
forest = false
|
federation = ${WRITEFREELY_FEDERATION:-true}
|
||||||
disable_drafts = false
|
public_stats = ${WRITEFREELY_PUBLIC_STATS:-false}
|
||||||
single_user = ${WRITEFREELY_SINGLE_USER:-false}
|
private = ${WRITEFREELY_PRIVATE:-false}
|
||||||
open_registration = ${WRITEFREELY_OPEN_REGISTRATION:-false}
|
local_timeline = ${WRITEFREELY_LOCAL_TIMELINE:-false}
|
||||||
min_username_len = ${WRITEFREELY_MIN_USERNAME_LEN:-3}
|
user_invites = ${WRITEFREELY_USER_INVITES}
|
||||||
max_blogs = ${WRITEFREELY_MAX_BLOG:-4}
|
|
||||||
federation = ${WRITEFREELY_FEDERATION:-true}
|
|
||||||
public_stats = ${WRITEFREELY_PUBLIC_STATS:-false}
|
|
||||||
monetization = false
|
|
||||||
notes_only = false
|
|
||||||
private = ${WRITEFREELY_PRIVATE:-false}
|
|
||||||
local_timeline = ${WRITEFREELY_LOCAL_TIMELINE:-false}
|
|
||||||
user_invites = ${WRITEFREELY_USER_INVITES}
|
|
||||||
update_checks = false
|
|
||||||
disable_password_auth = false
|
|
||||||
|
|
||||||
[email]
|
|
||||||
domain =
|
|
||||||
mailgun_private =
|
|
||||||
|
|
||||||
[oauth.slack]
|
|
||||||
client_id =
|
|
||||||
client_secret =
|
|
||||||
team_id =
|
|
||||||
callback_proxy =
|
|
||||||
callback_proxy_api =
|
|
||||||
|
|
||||||
[oauth.writeas]
|
|
||||||
client_id =
|
|
||||||
client_secret =
|
|
||||||
auth_location =
|
|
||||||
token_location =
|
|
||||||
inspect_location =
|
|
||||||
callback_proxy =
|
|
||||||
callback_proxy_api =
|
|
||||||
|
|
||||||
[oauth.gitlab]
|
|
||||||
client_id =
|
|
||||||
client_secret =
|
|
||||||
host =
|
|
||||||
display_name =
|
|
||||||
callback_proxy =
|
|
||||||
callback_proxy_api =
|
|
||||||
|
|
||||||
[oauth.gitea]
|
|
||||||
client_id =
|
|
||||||
client_secret =
|
|
||||||
host =
|
|
||||||
display_name =
|
|
||||||
callback_proxy =
|
|
||||||
callback_proxy_api =
|
|
||||||
|
|
||||||
[oauth.generic]
|
|
||||||
client_id =
|
|
||||||
client_secret =
|
|
||||||
host =
|
|
||||||
display_name =
|
|
||||||
callback_proxy =
|
|
||||||
callback_proxy_api =
|
|
||||||
token_endpoint =
|
|
||||||
inspect_endpoint =
|
|
||||||
auth_endpoint =
|
|
||||||
scope =
|
|
||||||
allow_disconnect = false
|
|
||||||
map_user_id =
|
|
||||||
map_username =
|
|
||||||
map_display_name =
|
|
||||||
map_email =
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 600 ./config.ini
|
${WRITEFREELY} --init-db
|
||||||
|
${WRITEFREELY} --gen-keys
|
||||||
initialize_database
|
|
||||||
generate_keys
|
|
||||||
create_admin_user
|
|
||||||
create_writer_user
|
|
||||||
|
|
||||||
exec ${WRITEFREELY}
|
exec ${WRITEFREELY}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
services:
|
|
||||||
writefreely-web:
|
|
||||||
container_name: writefreely-web
|
|
||||||
image: jrasanen/writefreely:latest
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
init: true
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
volumes:
|
|
||||||
- ./data:/data
|
|
||||||
ports:
|
|
||||||
- 8080:8080
|
|
||||||
depends_on:
|
|
||||||
- writefreely-db
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
writefreely-db:
|
|
||||||
container_name: writefreely-db
|
|
||||||
image: mariadb:latest
|
|
||||||
init: true
|
|
||||||
volumes:
|
|
||||||
- ./db-data:/var/lib/mysql
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "mariadb-admin ping -h localhost -u${MARIADB_USER} -p${MARIADB_PASSWORD} || exit 1"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 5
|
|
||||||
start_period: 10s
|
|
|
@ -1,15 +0,0 @@
|
||||||
services:
|
|
||||||
writefreely-web:
|
|
||||||
container_name: writefreely-web
|
|
||||||
image: jrasanen/writefreely:latest
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
init: true
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
volumes:
|
|
||||||
- ./data:/data
|
|
||||||
ports:
|
|
||||||
- 8080:8080
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue