-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bea2412
commit 2a922b0
Showing
9 changed files
with
301 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
configurations/ | ||
configurations/ | ||
|
||
.config.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# any-sync-coordinator | ||
FROM golang:1.19.11-bullseye AS any-sync-coordinator | ||
FROM golang:1.20-bullseye AS any-sync-coordinator | ||
LABEL MAINTAINER="Clément Michaud <[email protected]>" | ||
|
||
WORKDIR /usr/app | ||
|
||
RUN git clone https://github.com/anyproto/any-sync-coordinator.git && cd any-sync-coordinator && git checkout v0.2.8 | ||
RUN git clone https://github.com/anyproto/any-sync-coordinator.git && cd any-sync-coordinator && git checkout v0.2.6 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
RUN cd any-sync-coordinator && make deps && make build | ||
|
||
CMD ["/usr/app/any-sync-coordinator/bin/any-sync-coordinator", "-c", "/etc/anytype/coordinator.yml"] | ||
|
||
# any-sync-node | ||
FROM golang:1.19.11-bullseye AS any-sync-node | ||
FROM golang:1.20-bullseye AS any-sync-node | ||
LABEL MAINTAINER="Clément Michaud <[email protected]>" | ||
|
||
WORKDIR /usr/app | ||
|
@@ -22,12 +22,13 @@ RUN mkdir /usr/app/db | |
CMD ["/usr/app/any-sync-node/bin/any-sync-node", "-c", "/etc/anytype/sync_1.yml"] | ||
|
||
# any-sync-filenode | ||
FROM golang:1.19.11-bullseye AS any-sync-filenode | ||
FROM golang:1.20-bullseye AS any-sync-filenode | ||
LABEL MAINTAINER="Clément Michaud <[email protected]>" | ||
|
||
WORKDIR /usr/app | ||
|
||
RUN git clone https://github.com/anyproto/any-sync-filenode.git && cd any-sync-filenode && git checkout v0.3.4 | ||
# We point to the fork until this PR is merged: https://github.com/anyproto/any-sync-filenode/pull/22 | ||
RUN git clone https://github.com/clems4ever/any-sync-filenode.git && cd any-sync-filenode && git checkout v0.3.4-s3-creds | ||
RUN cd any-sync-filenode && make deps && make build | ||
|
||
CMD ["/usr/app/any-sync-filenode/bin/any-sync-filenode", "-c", "/etc/anytype/file_1.yml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Directory where the configuration files are generated | ||
config_dir: configurations | ||
|
||
# IP of the host where the backup node will run. | ||
# Note that, given how anytype services work, this IP must be accessible by your | ||
# devices. Hence, it can be a public IP or an IP from a LAN. | ||
host_ip: 192.168.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package backupnode | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/minio/minio-go/v7" | ||
"github.com/minio/minio-go/v7/pkg/credentials" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
func dockerCompose(args ...string) { | ||
cmd := exec.Command("docker-compose", args...) | ||
|
||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
|
||
err := cmd.Run() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func Bootstrap(configPath string) { | ||
GenerateConfig(configPath) | ||
|
||
dockerCompose("up", "--build", "-d") | ||
} | ||
|
||
func Initialize(ctx context.Context, configPath string) { | ||
b, err := os.ReadFile(configPath) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
var cfg Config | ||
err = yaml.Unmarshal(b, &cfg) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
endpoint := fmt.Sprintf("%s:9000", cfg.HostIP) | ||
accessKeyID := "miniorootuser" | ||
secretAccessKey := "miniorootpassword" | ||
|
||
// Initialize minio client object. | ||
minioClient, err := minio.New(endpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), | ||
}) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
bucketName := "any-sync-files" | ||
location := "eu-central-1" | ||
|
||
err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location}) | ||
if err != nil { | ||
// Check to see if we already own this bucket (which happens if you run this twice) | ||
exists, errBucketExists := minioClient.BucketExists(ctx, bucketName) | ||
if errBucketExists == nil && exists { | ||
log.Printf("We already own %s\n", bucketName) | ||
} else { | ||
log.Fatalln(err) | ||
} | ||
} else { | ||
log.Printf("Successfully created %s\n", bucketName) | ||
} | ||
} |
Oops, something went wrong.
Won't
git clone --depth 1 --branch v0.2.6 https://github.com/anyproto/any-sync-coordinator.git
do, instead of 3 commands?