add dockerfile and compose

This commit is contained in:
Umputun
2019-08-01 01:49:58 -05:00
parent 796c4f45eb
commit 5b173a05df
5 changed files with 67 additions and 40 deletions
+6 -4
View File
@@ -1,16 +1,18 @@
FROM umputun/baseimage:buildgo-latest as build-backend
ADD . /build/memory_store
WORKDIR /build/memory_store
#ADD . /build/memory_store
#WORKDIR /build/memory_store
ADD backend /build/backend
WORKDIR /build/backend/_example/memory_store
RUN go build -o memory_store -ldflags "-X main.revision=0.0.0 -s -w"
RUN go build -o /build/bin/memory_store -ldflags "-X main.revision=0.0.0 -s -w"
FROM umputun/baseimage:app-latest
WORKDIR /srv
COPY --from=build-backend /build/memory_store/memory_store /srv/memory_store
COPY --from=build-backend /build/bin/memory_store /srv/memory_store
RUN chown -R app:app /srv
EXPOSE 8080
+9
View File
@@ -2,3 +2,12 @@
`memory_store` illustrates how to make a custom storage plugin for remark42.
In order to run remark42 with memory_store copy provided `compose-dev-memstore.yml` to the root directory and run:
1. docker-compose -f compose-dev-memstore.yml build
1. docker-compose -f compose-dev-memstore.yml up
As usual, demo site will run on http://127.0.0.1:8080/web/
note: in order to work with the latest (current) version of master `go.mod` uses replacement directive for the backend package
. In real-life usage `replace github.com/umputun/remark/backend => ../../` should not be used.
@@ -0,0 +1,47 @@
# compose file demonstrating custom storage use. The memory_store (see backend/_example/memory_store) starts
# in a separate container and remark42 communicates to mem_store.r42 via STORE_RPC_API url
version: '2'
services:
remark42:
build:
context: .
dockerfile: Dockerfile
args:
- SKIP_BACKEND_TEST=true
- SKIP_FRONTEND_TEST=true
image: umputun/remark42:dev
container_name: "remark42"
hostname: "remark42"
restart: always
ports:
- "8080:8080" # primary rest server
- "8084:8084" # local oauth2 server
environment:
- REMARK_URL=http://127.0.0.1:8080
- SECRET=123456
- BACKUP_PATH=/srv/var/backup
- DEBUG=true
- EMOJI=true
- AUTH_ANON=true
- AUTH_DEV=true
- ADMIN_TYPE=rpc
- ADMIN_RPC_API=http://mem_store.r42:8080/cmd
- STORE_TYPE=rpc
- STORE_RPC_API=http://mem_store.r42:8080/cmd
mem_store.r42:
image: umputun/mem_store.r42
build:
context: .
dockerfile: backend/_example/memory_store/Dockerfile
container_name: "mem_store.r42"
hostname: "mem_store.r42"
environment:
- API=/cmd
- SECRET=123456
- DEBUG=true
@@ -1,33 +0,0 @@
version: '2'
services:
remark:
image: umputun/remark42:dev
container_name: "remark42"
hostname: "remark42"
restart: always
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
ports:
- "8080:8080"
environment:
- REMARK_URL
- SECRET
- STORE_BOLT_PATH=/srv/var/db
- BACKUP_PATH=/srv/var/backup
- DEBUG=true
- EMOJI=true
- AUTH_ANON=true
- AUTH_DEV=true
-
volumes:
- ./var:/srv/var
mem_storage:
build: .
+5 -3
View File
@@ -48,15 +48,17 @@ func main() {
AuthPasswd: opts.AuthPasswd,
Version: revision,
AppName: "remark42-memory",
Logger: log.Default(),
}
srv := server.NewRPC(dataStore, adminStore, &rpcServer)
admRec := accessor.AdminRec{
SiteID: "example",
IDs: []string{"id1", "id2"},
SiteID: "remark",
IDs: []string{"dev_user"},
Email: "admin@example.com",
}
adminStore.Set("example", admRec)
adminStore.Set("remark", admRec)
err := srv.Run(opts.Port)
log.Printf("[ERROR] server failed or terminated, %+v", err)