diff --git a/Dockerfile b/Dockerfile index 31285cc..2d4563d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,27 @@ FROM golang:1.12-alpine AS build RUN apk add nodejs nodejs-npm make g++ ca-certificates git sqlite-dev && \ npm install -g less less-plugin-clean-css && \ go get -u github.com/jteeuwen/go-bindata/... WORKDIR /src COPY ./go.mod ./go.sum ./ RUN go mod download COPY . . -RUN make assets ui && cd cmd/writefreely && go build -v -tags='sqlite' +RUN cd cmd/writefreely && go build -v -tags='sqlite' +RUN make assets ui RUN mkdir -p \ /home/writefreely/static /home/writefreely/templates /home/writefreely/pages && \ - cp -r templates/ pages/ static/ /home/writefreely + cp -r templates/ pages/ static/ /home/writefreely && \ + cp config.ini.example /home/writefreely/config.ini FROM alpine AS final # TODO user nobody or similar COPY --from=build /src/cmd/writefreely/writefreely /bin COPY --from=build /home /home EXPOSE 8080 WORKDIR /home/writefreely -ENTRYPOINT [ "writefreely" ] \ No newline at end of file +ENTRYPOINT [ "writefreely" ] diff --git a/config.ini.example b/config.ini.example index dcbd6ee..bb74d33 100644 --- a/config.ini.example +++ b/config.ini.example @@ -1,26 +1,27 @@ [server] hidden_host = port = 8080 +bind = 0.0.0.0 [database] type = mysql username = root password = changeme database = writefreely host = db port = 3306 [app] site_name = WriteFreely Example Blog! host = http://localhost:8080 theme = write disable_js = false webfonts = true single_user = true open_registration = false min_username_len = 3 max_blogs = 1 federation = true public_stats = true private = false diff --git a/docker-compose.sqlite.yml b/docker-compose.sqlite.yml deleted file mode 100644 index 31594fb..0000000 --- a/docker-compose.sqlite.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: "3" -services: - web: - image: robjloranger/writefreely:v0.10.0 - volumes: - - ./keys:/home/writefreely/keys - - ./config.ini:/home/writefreely/config.ini - - ./writefreely.db:/home/writefreely/writefreely.db - ports: - - "8080:8080" - networks: - - writefreely - restart: unless-stopped - -networks: - writefreely: \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 65dbf0d..8086f69 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,30 +1,30 @@ version: "3" services: web: - image: robjloranger/writefreely:v0.10.0 + image: writeas/writefreely:latest volumes: - - ./keys:/home/writefreely/keys - - ./config.ini:/home/writefreely/config.ini + - web-data:/home/writefreely ports: - "8080:8080" networks: - writefreely depends_on: - db restart: unless-stopped db: image: "mariadb:latest" volumes: - - db-data:/var/lib/mysql/data + - db-data:/var/lib/mysql networks: - writefreely environment: - MYSQL_DATABASE=writefreely - MYSQL_ROOT_PASSWORD=changeme restart: unless-stopped volumes: - db-data: + web-data: + db-data: networks: - writefreely: \ No newline at end of file + writefreely: diff --git a/docker-setup.sh b/docker-setup.sh new file mode 100755 index 0000000..b7d74c5 --- /dev/null +++ b/docker-setup.sh @@ -0,0 +1,23 @@ +#! /bin/bash +# this script will configure and intialize the persitent data needed +# for a writefreely instance using the docker-compose.yml in this repo + +# start database +docker run -d --volume=writefreely_db-data:/var/lib/mysql \ +--name=db \ +-e "MYSQL_DATABASE=writefreely" \ +-e "MYSQL_ROOT_PASSWORD=changeme" \ +-p 3306:3306 \ +mariadb:latest + +# create new asset signing keys +docker run --volume=writefreely_web-data:/home/writefreely writeas/writefreely:latest "-gen-keys" + +# generate new configuration and initialize database +docker run -it --volume=writefreely_web-data:/home/writefreely \ +--link db:db \ +writeas/writefreely:latest "-config" + +# clean up detached database container +docker container stop db +docker container rm db \ No newline at end of file