finish updating dockerfile and compose

this simplifies the compose file a bit, makes the dockerfile more
efficient and reintroduces the setup script that works with the new
image.

also adds a default 'bind' of 0.0.0.0 to the server block in
config.ini.example.
This commit is contained in:
Rob Loranger 2019-09-16 12:53:45 -07:00
parent 2ec67fc26a
commit 34b5581026
No known key found for this signature in database
GPG key ID: D6F1633A4F0903B8
5 changed files with 35 additions and 25 deletions

View file

@ -8,11 +8,13 @@ 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
@ -22,4 +24,4 @@ COPY --from=build /home /home
EXPOSE 8080
WORKDIR /home/writefreely
ENTRYPOINT [ "writefreely" ]
ENTRYPOINT [ "writefreely" ]

View file

@ -1,6 +1,7 @@
[server]
hidden_host =
port = 8080
bind = 0.0.0.0
[database]
type = mysql

View file

@ -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:

View file

@ -1,10 +1,9 @@
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:
@ -15,7 +14,7 @@ services:
db:
image: "mariadb:latest"
volumes:
- db-data:/var/lib/mysql/data
- db-data:/var/lib/mysql
networks:
- writefreely
environment:
@ -24,7 +23,8 @@ services:
restart: unless-stopped
volumes:
db-data:
web-data:
db-data:
networks:
writefreely:
writefreely:

23
docker-setup.sh Executable file
View file

@ -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