refactor Dockerfile to work with current version

this changes the Dockerfile a bit to work with the current version
0.10.0 of writefreely, and removes the docker-setup script for now.

Kind of a work in progress but wanted to share with those interested.
This commit is contained in:
Rob Loranger 2019-09-14 10:59:35 -07:00
parent 8557119451
commit 2ec67fc26a
No known key found for this signature in database
GPG key ID: D6F1633A4F0903B8
8 changed files with 45 additions and 39 deletions

View file

@ -1,2 +1,4 @@
Dockerfile
.git
config.ini
writefreely.db

View file

@ -1,35 +1,25 @@
# 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 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 make assets ui && cd cmd/writefreely && go build -v -tags='sqlite'
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
# Final image
FROM alpine:3.8
FROM alpine AS final
RUN apk add --no-cache openssl ca-certificates
COPY --from=build --chown=daemon:daemon /stage /go
# TODO user nobody or similar
COPY --from=build /src/cmd/writefreely/writefreely /bin
COPY --from=build /home /home
WORKDIR /go
VOLUME /go/keys
EXPOSE 8080
USER daemon
ENTRYPOINT ["cmd/writefreely/writefreely"]
WORKDIR /home/writefreely
ENTRYPOINT [ "writefreely" ]

View file

@ -19,6 +19,9 @@ ci: ci-assets deps
build: assets deps
cd cmd/writefreely; $(GOBUILD) -v -tags='sqlite'
build-no-git: assets deps
cd cmd/writefreely; $(GOCMD) build -v -tags='sqlite'
build-no-sqlite: assets-no-sqlite deps-no-sqlite
cd cmd/writefreely; $(GOBUILD) -v -o $(BINARY_NAME)

View file

@ -12,8 +12,9 @@
package config
import (
"gopkg.in/ini.v1"
"strings"
"gopkg.in/ini.v1"
)
const (

16
docker-compose.sqlite.yml Normal file
View file

@ -0,0 +1,16 @@
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,10 @@
version: "3"
services:
web:
build: .
image: robjloranger/writefreely:v0.10.0
volumes:
- "web-data:/go/src/app"
- "./config.ini.example:/go/src/app/config.ini"
- ./keys:/home/writefreely/keys
- ./config.ini:/home/writefreely/config.ini
ports:
- "8080:8080"
networks:
@ -15,7 +15,6 @@ services:
db:
image: "mariadb:latest"
volumes:
- "./schema.sql:/tmp/schema.sql"
- db-data:/var/lib/mysql/data
networks:
- writefreely
@ -25,8 +24,7 @@ services:
restart: unless-stopped
volumes:
web-data:
db-data:
networks:
writefreely:
writefreely:

View file

@ -1,4 +0,0 @@
#!/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

2
go.mod
View file

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