mirror of https://github.com/writeas/writefreely
commit
121a21d900
@ -0,0 +1,34 @@ |
||||
FROM golang:alpine AS build |
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/writefreely/writefreely" |
||||
LABEL org.opencontainers.image.description="WriteFreely is a clean, minimalist publishing platform made for writers. Start a blog, share knowledge within your organization, or build a community around the shared act of writing." |
||||
|
||||
RUN apk update --no-cache && \ |
||||
apk upgrade --no-cache && \ |
||||
apk add --no-cache nodejs npm make g++ git sqlite-dev patch && \ |
||||
npm install -g less less-plugin-clean-css && \ |
||||
mkdir -p /go/src/github.com/writefreely/writefreely |
||||
|
||||
COPY . /go/src/github.com/writefreely/writefreely |
||||
WORKDIR /go/src/github.com/writefreely/writefreely |
||||
ENV NODE_OPTIONS=--openssl-legacy-provider |
||||
RUN cat ossl_legacy.cnf >> /etc/ssl/openssl.cnf && \ |
||||
make build && \ |
||||
make ui |
||||
|
||||
FROM alpine |
||||
|
||||
RUN apk update --no-cache && \ |
||||
apk upgrade --no-cache && \ |
||||
apk add --no-cache openssl ca-certificates && \ |
||||
mkdir /usr/share/writefreely |
||||
|
||||
COPY --from=build /go/src/github.com/writefreely/writefreely/cmd/writefreely/writefreely /usr/bin |
||||
COPY --from=build /go/src/github.com/writefreely/writefreely/pages /usr/share/writefreely/pages |
||||
COPY --from=build /go/src/github.com/writefreely/writefreely/static /usr/share/writefreely/static |
||||
COPY --from=build /go/src/github.com/writefreely/writefreely/templates /usr/share/writefreely/templates |
||||
|
||||
ENV WRITEFREELY_DOCKER=True |
||||
ENV HOME=/data |
||||
WORKDIR /data |
||||
CMD ["/usr/bin/writefreely"] |
@ -0,0 +1,49 @@ |
||||
/* |
||||
* Copyright © 2024 Musing Studio LLC. |
||||
* |
||||
* This file is part of WriteFreely. |
||||
* |
||||
* WriteFreely is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License, included |
||||
* in the LICENSE file in this source code package. |
||||
*/ |
||||
|
||||
package writefreely |
||||
|
||||
import ( |
||||
"database/sql" |
||||
"fmt" |
||||
"github.com/writeas/web-core/activitystreams" |
||||
"github.com/writeas/web-core/log" |
||||
) |
||||
|
||||
func apAddRemoteUser(app *App, t *sql.Tx, fullActor *activitystreams.Person) (int64, error) { |
||||
// Add remote user locally, since it wasn't found before
|
||||
res, err := t.Exec("INSERT INTO remoteusers (actor_id, inbox, shared_inbox, url) VALUES (?, ?, ?, ?)", fullActor.ID, fullActor.Inbox, fullActor.Endpoints.SharedInbox, fullActor.URL) |
||||
if err != nil { |
||||
t.Rollback() |
||||
return -1, fmt.Errorf("couldn't add new remoteuser in DB: %v", err) |
||||
} |
||||
|
||||
remoteUserID, err := res.LastInsertId() |
||||
if err != nil { |
||||
t.Rollback() |
||||
return -1, fmt.Errorf("no lastinsertid for followers, rolling back: %v", err) |
||||
} |
||||
|
||||
// Add in key
|
||||
_, err = t.Exec("INSERT INTO remoteuserkeys (id, remote_user_id, public_key) VALUES (?, ?, ?)", fullActor.PublicKey.ID, remoteUserID, fullActor.PublicKey.PublicKeyPEM) |
||||
if err != nil { |
||||
if !app.db.isDuplicateKeyErr(err) { |
||||
t.Rollback() |
||||
log.Error("Couldn't add follower keys in DB: %v\n", err) |
||||
return -1, fmt.Errorf("couldn't add follower keys in DB: %v", err) |
||||
} else { |
||||
t.Rollback() |
||||
log.Error("Couldn't add follower keys in DB: %v\n", err) |
||||
return -1, fmt.Errorf("couldn't add follower keys in DB: %v", err) |
||||
} |
||||
} |
||||
|
||||
return remoteUserID, nil |
||||
} |
@ -0,0 +1,25 @@ |
||||
services: |
||||
app: |
||||
image: writefreely |
||||
container_name: writefreely |
||||
volumes: |
||||
- ./data:/data |
||||
ports: |
||||
- 127.0.0.1:8080:8080 |
||||
depends_on: |
||||
- db |
||||
restart: unless-stopped |
||||
|
||||
db: |
||||
image: lscr.io/linuxserver/mariadb |
||||
container_name: writefreely-mariadb |
||||
volumes: |
||||
- ./db:/config |
||||
environment: |
||||
- PUID=65534 |
||||
- PGID=65534 |
||||
- TZ=Etc/UTC |
||||
- MYSQL_DATABASE=writefreely |
||||
- MYSQL_USER=writefreely |
||||
- MYSQL_PASSWORD=P@ssw0rd |
||||
restart: unless-stopped |
@ -0,0 +1,38 @@ |
||||
/* |
||||
* Copyright © 2024 Musing Studio LLC. |
||||
* |
||||
* This file is part of WriteFreely. |
||||
* |
||||
* WriteFreely is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License, included |
||||
* in the LICENSE file in this source code package. |
||||
*/ |
||||
|
||||
package migrations |
||||
|
||||
func supportRemoteLikes(db *datastore) error { |
||||
t, err := db.Begin() |
||||
if err != nil { |
||||
t.Rollback() |
||||
return err |
||||
} |
||||
|
||||
_, err = t.Exec(`CREATE TABLE remote_likes ( |
||||
post_id ` + db.typeChar(16) + ` NOT NULL, |
||||
remote_user_id ` + db.typeInt() + ` NOT NULL, |
||||
created ` + db.typeDateTime() + ` NOT NULL, |
||||
PRIMARY KEY (post_id,remote_user_id) |
||||
)`) |
||||
if err != nil { |
||||
t.Rollback() |
||||
return err |
||||
} |
||||
|
||||
err = t.Commit() |
||||
if err != nil { |
||||
t.Rollback() |
||||
return err |
||||
} |
||||
|
||||
return nil |
||||
} |
Loading…
Reference in new issue