mirror of
https://github.com/writeas/writefreely
synced 2025-02-01 16:06:41 +01:00
Merge remote-tracking branch 'upstream/master' into codehighlight
* upstream/master: Re-add https in log message Also use bind address on standalone redirect Allow 'bind' in config to specify bind address Only log ActivityPub info when debugging Bump version to 0.4 Move softwareVer to var() block Add @koehn to AUTHORS Add `make release-docker` Move docker build to `make build-docker` extracted docker command a la `go` and `make` added docker support to `make release` removed an unnecessary debugging statement added .git to make builds cache more effectively and run faster switched to much smaller alpine image since golang not required at runtime Updated Dockerfile to produce smaller image with minimum content and a few extra features; added .dockerignore
This commit is contained in:
commit
b034a08350
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
Dockerfile
|
||||
.git
|
@ -5,4 +5,4 @@ WriteFreely is built by [Matt Baer](https://github.com/thebaer), with contributi
|
||||
* [Jean-Francois Arseneau](https://github.com/TheJF)
|
||||
* [Ben Overmyer](https://github.com/BenOvermyer)
|
||||
* [Marcel van der Boom](https://github.com/mrvdb)
|
||||
|
||||
* [Brad Koehn](https://github.com/koehn)
|
||||
|
21
Dockerfile
21
Dockerfile
@ -1,4 +1,4 @@
|
||||
FROM golang:1.11.2-alpine3.8
|
||||
FROM golang:1.11.2-alpine3.8 as build
|
||||
|
||||
RUN apk add --update nodejs nodejs-npm make git
|
||||
RUN npm install -g less
|
||||
@ -11,5 +11,22 @@ RUN make install
|
||||
RUN make ui
|
||||
RUN make deps
|
||||
|
||||
RUN mkdir /stage && \
|
||||
cp -R /go/bin \
|
||||
/go/src/app/templates \
|
||||
/go/src/app/static \
|
||||
/go/src/app/schema.sql \
|
||||
/go/src/app/pages \
|
||||
/go/src/app/keys \
|
||||
/stage
|
||||
|
||||
FROM alpine:3.8
|
||||
|
||||
COPY --from=build --chown=daemon:daemon /stage /go
|
||||
|
||||
WORKDIR /go
|
||||
VOLUME /go/keys
|
||||
EXPOSE 8080
|
||||
CMD ["writefreely"]
|
||||
USER daemon
|
||||
|
||||
CMD ["bin/writefreely"]
|
||||
|
10
Makefile
10
Makefile
@ -7,6 +7,8 @@ GOBUILD=$(GOCMD) build $(LDFLAGS)
|
||||
GOTEST=$(GOCMD) test $(LDFLAGS)
|
||||
GOGET=$(GOCMD) get
|
||||
BINARY_NAME=writefreely
|
||||
DOCKERCMD=docker
|
||||
IMAGE_NAME=writeas/writefreely
|
||||
|
||||
all : build
|
||||
|
||||
@ -22,6 +24,9 @@ build-windows: deps
|
||||
build-darwin: deps
|
||||
cd cmd/writefreely; GOOS=darwin GOARCH=amd64 $(GOBUILD) -v
|
||||
|
||||
build-docker :
|
||||
$(DOCKERCMD) build -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(GITREV) .
|
||||
|
||||
test:
|
||||
$(GOTEST) -v ./...
|
||||
|
||||
@ -54,6 +59,11 @@ release : clean ui
|
||||
$(MAKE) build-windows
|
||||
cp cmd/writefreely/$(BINARY_NAME).exe build
|
||||
cd build; zip -r ../$(BINARY_NAME)_$(GITREV)_windows_amd64.zip ./*
|
||||
$(MAKE) build-docker
|
||||
$(MAKE) release-docker
|
||||
|
||||
release-docker :
|
||||
$(DOCKERCMD) push $(IMAGE_NAME)
|
||||
|
||||
ui : force_look
|
||||
cd less/; $(MAKE) $(MFLAGS)
|
||||
|
@ -254,7 +254,9 @@ func handleFetchCollectionInbox(app *app, w http.ResponseWriter, r *http.Request
|
||||
// 2) Errors are propagated to res.Deserialize call below
|
||||
m["@context"] = []string{activitystreams.Namespace}
|
||||
b, _ := json.Marshal(m)
|
||||
log.Info("Follow: %s", b)
|
||||
if debugging {
|
||||
log.Info("Follow: %s", b)
|
||||
}
|
||||
|
||||
_, followID := f.GetId()
|
||||
if followID == nil {
|
||||
@ -287,7 +289,9 @@ func handleFetchCollectionInbox(app *app, w http.ResponseWriter, r *http.Request
|
||||
|
||||
m["@context"] = []string{activitystreams.Namespace}
|
||||
b, _ := json.Marshal(m)
|
||||
log.Info("Undo: %s", b)
|
||||
if debugging {
|
||||
log.Info("Undo: %s", b)
|
||||
}
|
||||
|
||||
a.AppendObject(u.Raw())
|
||||
_, to = u.GetActor(0)
|
||||
|
28
app.go
28
app.go
@ -36,12 +36,12 @@ const (
|
||||
softwareURL = "https://writefreely.org"
|
||||
)
|
||||
|
||||
// Software version can be set from git env using -ldflags
|
||||
var softwareVer = "0.3"
|
||||
|
||||
var (
|
||||
debugging bool
|
||||
|
||||
// Software version can be set from git env using -ldflags
|
||||
softwareVer = "0.4"
|
||||
|
||||
// DEPRECATED VARS
|
||||
// TODO: pass app.cfg into GetCollection* calls so we can get these values
|
||||
// from Collection methods and we no longer need these.
|
||||
@ -404,22 +404,28 @@ func Serve() {
|
||||
http.Handle("/", r)
|
||||
|
||||
// Start web application server
|
||||
var bindAddress = app.cfg.Server.Bind
|
||||
if bindAddress == "" {
|
||||
bindAddress = "localhost"
|
||||
}
|
||||
if app.cfg.IsSecureStandalone() {
|
||||
log.Info("Serving redirects on http://localhost:80")
|
||||
log.Info("Serving redirects on http://%s:80", bindAddress)
|
||||
go func() {
|
||||
err = http.ListenAndServe(":80", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, app.cfg.App.Host, http.StatusMovedPermanently)
|
||||
}))
|
||||
err = http.ListenAndServe(
|
||||
fmt.Sprintf("%s:80", bindAddress), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, app.cfg.App.Host, http.StatusMovedPermanently)
|
||||
}))
|
||||
log.Error("Unable to start redirect server: %v", err)
|
||||
}()
|
||||
|
||||
log.Info("Serving on https://localhost:443")
|
||||
log.Info("Serving on https://%s:443", bindAddress)
|
||||
log.Info("---")
|
||||
err = http.ListenAndServeTLS(":443", app.cfg.Server.TLSCertPath, app.cfg.Server.TLSKeyPath, nil)
|
||||
err = http.ListenAndServeTLS(
|
||||
fmt.Sprintf("%s:443", bindAddress), app.cfg.Server.TLSCertPath, app.cfg.Server.TLSKeyPath, nil)
|
||||
} else {
|
||||
log.Info("Serving on http://localhost:%d\n", app.cfg.Server.Port)
|
||||
log.Info("Serving on http://%s:%d\n", bindAddress, app.cfg.Server.Port)
|
||||
log.Info("---")
|
||||
err = http.ListenAndServe(fmt.Sprintf(":%d", app.cfg.Server.Port), nil)
|
||||
err = http.ListenAndServe(fmt.Sprintf("%s:%d", bindAddress, app.cfg.Server.Port), nil)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error("Unable to start: %v", err)
|
||||
|
@ -12,6 +12,7 @@ type (
|
||||
ServerCfg struct {
|
||||
HiddenHost string `ini:"hidden_host"`
|
||||
Port int `ini:"port"`
|
||||
Bind string `ini:"bind"`
|
||||
|
||||
TLSCertPath string `ini:"tls_cert_path"`
|
||||
TLSKeyPath string `ini:"tls_key_path"`
|
||||
@ -60,6 +61,7 @@ func New() *Config {
|
||||
return &Config{
|
||||
Server: ServerCfg{
|
||||
Port: 8080,
|
||||
Bind: "localhost", /* IPV6 support when not using localhost? */
|
||||
},
|
||||
Database: DatabaseCfg{
|
||||
Type: "mysql",
|
||||
|
Loading…
x
Reference in New Issue
Block a user