Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
|
42f6733980 | ||
|
66d9ecf387 | ||
|
08403ca845 | ||
|
82451aebfc | ||
|
4bc0b46368 | ||
|
34b5581026 | ||
|
2ec67fc26a |
6 changed files with 58 additions and 39 deletions
53
Dockerfile
53
Dockerfile
|
@ -1,35 +1,36 @@
|
|||
# Build image
|
||||
FROM golang:1.12-alpine as build
|
||||
FROM golang:1.12-alpine AS build
|
||||
|
||||
RUN apk add --update nodejs nodejs-npm make g++ git sqlite-dev
|
||||
RUN npm install -g less less-plugin-clean-css
|
||||
RUN go get -u github.com/jteeuwen/go-bindata/...
|
||||
RUN apk add --update 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/...
|
||||
|
||||
RUN mkdir -p /go/src/github.com/writeas/writefreely
|
||||
WORKDIR /go/src/github.com/writeas/writefreely
|
||||
WORKDIR /src
|
||||
COPY ./go.mod ./go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN cd cmd/writefreely && go build -v -tags='sqlite'
|
||||
RUN make assets ui
|
||||
|
||||
ENV GO111MODULE=on
|
||||
RUN make build \
|
||||
&& make ui
|
||||
RUN mkdir /stage && \
|
||||
cp -R /go/bin \
|
||||
/go/src/github.com/writeas/writefreely/templates \
|
||||
/go/src/github.com/writeas/writefreely/static \
|
||||
/go/src/github.com/writeas/writefreely/pages \
|
||||
/go/src/github.com/writeas/writefreely/keys \
|
||||
/go/src/github.com/writeas/writefreely/cmd \
|
||||
/stage
|
||||
RUN mkdir -p \
|
||||
/home/writefreely/static /home/writefreely/templates /home/writefreely/pages && \
|
||||
cp -r templates/ pages/ static/ /home/writefreely && \
|
||||
cp config.ini.example /home/writefreely/config.ini
|
||||
|
||||
# Final image
|
||||
FROM alpine:3.8
|
||||
FROM alpine AS dev
|
||||
|
||||
RUN apk add --no-cache openssl ca-certificates
|
||||
COPY --from=build --chown=daemon:daemon /stage /go
|
||||
COPY --from=build /src/cmd/writefreely/writefreely /bin
|
||||
COPY --from=build /home /home
|
||||
|
||||
WORKDIR /go
|
||||
VOLUME /go/keys
|
||||
EXPOSE 8080
|
||||
USER daemon
|
||||
WORKDIR /home/writefreely
|
||||
ENTRYPOINT [ "writefreely" ]
|
||||
|
||||
ENTRYPOINT ["cmd/writefreely/writefreely"]
|
||||
FROM alpine AS prod
|
||||
|
||||
|
||||
RUN apk add ca-certificates openssl
|
||||
COPY --from=dev . .
|
||||
|
||||
EXPOSE 80 443
|
||||
WORKDIR /home/writefreely
|
||||
ENTRYPOINT [ "writefreely" ]
|
|
@ -1,6 +1,7 @@
|
|||
[server]
|
||||
hidden_host =
|
||||
port = 8080
|
||||
bind = 0.0.0.0
|
||||
|
||||
[database]
|
||||
type = mysql
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"gopkg.in/ini.v1"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/ini.v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
version: "3"
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
image: writeas/writefreely:latest
|
||||
volumes:
|
||||
- "web-data:/go/src/app"
|
||||
- "./config.ini.example:/go/src/app/config.ini"
|
||||
- web-data:/home/writefreely
|
||||
ports:
|
||||
- "8080:8080"
|
||||
networks:
|
||||
|
@ -15,8 +14,7 @@ services:
|
|||
db:
|
||||
image: "mariadb:latest"
|
||||
volumes:
|
||||
- "./schema.sql:/tmp/schema.sql"
|
||||
- db-data:/var/lib/mysql/data
|
||||
- db-data:/var/lib/mysql
|
||||
networks:
|
||||
- writefreely
|
||||
environment:
|
||||
|
@ -25,8 +23,8 @@ services:
|
|||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
web-data:
|
||||
db-data:
|
||||
web-data:
|
||||
db-data:
|
||||
|
||||
networks:
|
||||
writefreely:
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
#!/bin/bash
|
||||
docker-compose exec db sh -c 'exec mysql -u root -pchangeme writefreely < /tmp/schema.sql'
|
||||
docker exec writefreely_web_1 writefreely --gen-keys
|
||||
docker exec -it writefreely_web_1 writefreely --config
|
||||
#! /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 --rm -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 --rm --volume=writefreely_web-data:/home/writefreely writeas/writefreely:latest "-gen-keys"
|
||||
|
||||
# generate new configuration and initialize database
|
||||
docker run --rm -it --volume=writefreely_web-data:/home/writefreely \
|
||||
--link db:db \
|
||||
writeas/writefreely:latest "-config"
|
||||
|
||||
# clean up detached database container
|
||||
docker container stop db
|
2
go.mod
2
go.mod
|
@ -63,7 +63,7 @@ require (
|
|||
github.com/writeas/slug v1.2.0
|
||||
github.com/writeas/web-core v1.0.0
|
||||
github.com/writefreely/go-nodeinfo v1.2.0
|
||||
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f // indirect
|
||||
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f
|
||||
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
|
||||
golang.org/x/net v0.0.0-20190206173232-65e2d4e15006 // indirect
|
||||
golang.org/x/sys v0.0.0-20190209173611-3b5209105503 // indirect
|
||||
|
|
Loading…
Add table
Reference in a new issue