Skip to content

Commit

Permalink
chore:ci: pull tags/v0.22.5 from usememos/memos
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthalles committed Sep 3, 2024
2 parents a91282c + 852ff5a commit 0420405
Show file tree
Hide file tree
Showing 234 changed files with 4,297 additions and 4,434 deletions.
2 changes: 1 addition & 1 deletion memos/.github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.1
version: v1.56.1
args: --verbose --timeout=3m
skip-cache: true

Expand Down
6 changes: 2 additions & 4 deletions memos/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ issues:
# https://golangci-lint.run/usage/configuration/#command-line-options
exclude:
- Rollback
- logger.Sync
- pgInstance.Stop
- fmt.Printf
- Enter(.*)_(.*)
- Exit(.*)_(.*)

linters-settings:
goimports:
Expand Down Expand Up @@ -75,6 +71,8 @@ linters-settings:
disabled: true
- name: if-return
disabled: true
- name: max-control-nesting
disabled: true
gocritic:
disabled-checks:
- ifElseChain
Expand Down
6 changes: 2 additions & 4 deletions memos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ WORKDIR /backend-build
COPY . .
COPY --from=frontend /frontend-build/web/dist /backend-build/server/router/frontend/dist

RUN CGO_ENABLED=0 go build -o memos ./bin/memos/main.go
RUN CGO_ENABLED=0 go build -ldflags='-s -w' -trimpath -o memos ./bin/memos/main.go

# Make workspace with above generated files.
FROM alpine:latest AS monolithic
FROM gcr.io/distroless/static-debian12:latest AS monolithic
WORKDIR /usr/local/memos

RUN apk add --no-cache tzdata
ENV TZ="UTC"

COPY --from=backend /backend-build/memos /usr/local/memos/

EXPOSE 5230

# Directory to store the data, which can be referenced as the mounting point.
RUN mkdir -p /var/opt/memos
VOLUME /var/opt/memos

ENV MEMOS_MODE="prod"
Expand Down
10 changes: 4 additions & 6 deletions memos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ docker run -d --name memos -p 5230:5230 -v ~/.memos/:/var/opt/memos neosmemo/mem
```

> [!NOTE]
> This command is only applicable for Unix/Linux systems. For Windows, please refer to the detailed [documentation](https://www.usememos.com/docs/install/self-hosting).
> This command is only applicable for Unix/Linux systems. For Windows, please refer to the detailed [documentation](https://www.usememos.com/docs/install/container-install#docker-on-windows).
>
> The `~/.memos/` directory will be used as the data directory on your local machine, while `/var/opt/memos` is the directory of the volume in Docker and should not be modified.
Expand All @@ -39,13 +39,11 @@ Learn more about [other installation methods](https://www.usememos.com/docs/inst

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. We greatly appreciate any contributions you make. Thank you for being a part of our community! 🥰

## Internationalization
## Sponsorship

Memos supports multiple languages. You can help us translate Memos into your language. We use Weblate to manage translations.
If you find Memos helpful, please consider sponsoring us. Your support will help us to continue developing and maintaining the project.

<a href="https://hosted.weblate.org/engage/memos-i18n/">
<img src="https://hosted.weblate.org/widget/memos-i18n/english/287x66-grey.png" alt="Translation status" />
</a>
❤️ Thanks to the following sponsors and backers: **[yourselfhosted](https://github.com/yourselfhosted)**, **[Burning_Wipf](https://github.com/KUKARAF)**, _[...see more](https://github.com/sponsors/usememos)_.

## Star history

Expand Down
67 changes: 22 additions & 45 deletions memos/bin/memos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ var (
Short: `An open source, lightweight note-taking service. Easily capture and share your great thoughts.`,
Run: func(_ *cobra.Command, _ []string) {
instanceProfile := &profile.Profile{
Mode: viper.GetString("mode"),
Addr: viper.GetString("addr"),
Port: viper.GetInt("port"),
Data: viper.GetString("data"),
Driver: viper.GetString("driver"),
DSN: viper.GetString("dsn"),
Public: viper.GetBool("public"),
PasswordAuth: viper.GetBool("password-auth"),
Version: version.GetCurrentVersion(viper.GetString("mode")),
Mode: viper.GetString("mode"),
Addr: viper.GetString("addr"),
Port: viper.GetInt("port"),
Data: viper.GetString("data"),
Driver: viper.GetString("driver"),
DSN: viper.GetString("dsn"),
InstanceURL: viper.GetString("instance-url"),
Version: version.GetCurrentVersion(viper.GetString("mode")),
}
if err := instanceProfile.Validate(); err != nil {
panic(err)
Expand All @@ -57,16 +56,11 @@ var (
slog.Error("failed to create db driver", "error", err)
return
}
if err := dbDriver.Migrate(ctx); err != nil {
cancel()
slog.Error("failed to migrate database", "error", err)
return
}

storeInstance := store.New(dbDriver, instanceProfile)
if err := storeInstance.MigrateManually(ctx); err != nil {
if err := storeInstance.Migrate(ctx); err != nil {
cancel()
slog.Error("failed to migrate manually", "error", err)
slog.Error("failed to migrate", "error", err)
return
}

Expand Down Expand Up @@ -105,58 +99,43 @@ var (
)

func init() {
viper.SetDefault("mode", "demo")
viper.SetDefault("mode", "dev")
viper.SetDefault("driver", "sqlite")
viper.SetDefault("addr", "")
viper.SetDefault("port", 8081)
viper.SetDefault("public", false)
viper.SetDefault("password-auth", true)

rootCmd.PersistentFlags().String("mode", "demo", `mode of server, can be "prod" or "dev" or "demo"`)
rootCmd.PersistentFlags().String("mode", "dev", `mode of server, can be "prod" or "dev" or "demo"`)
rootCmd.PersistentFlags().String("addr", "", "address of server")
rootCmd.PersistentFlags().Int("port", 8081, "port of server")
rootCmd.PersistentFlags().String("data", "", "data directory")
rootCmd.PersistentFlags().String("driver", "sqlite", "database driver")
rootCmd.PersistentFlags().String("dsn", "", "database source name(aka. DSN)")
rootCmd.PersistentFlags().Bool("public", false, "")
rootCmd.PersistentFlags().Bool("password-auth", true, "")
rootCmd.PersistentFlags().String("instance-url", "", "the url of your memos instance")

err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode"))
if err != nil {
panic(err)
}
err = viper.BindPFlag("addr", rootCmd.PersistentFlags().Lookup("addr"))
if err != nil {
if err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode")); err != nil {
panic(err)
}
err = viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port"))
if err != nil {
if err := viper.BindPFlag("addr", rootCmd.PersistentFlags().Lookup("addr")); err != nil {
panic(err)
}
err = viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data"))
if err != nil {
if err := viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port")); err != nil {
panic(err)
}
err = viper.BindPFlag("driver", rootCmd.PersistentFlags().Lookup("driver"))
if err != nil {
if err := viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data")); err != nil {
panic(err)
}
err = viper.BindPFlag("dsn", rootCmd.PersistentFlags().Lookup("dsn"))
if err != nil {
if err := viper.BindPFlag("driver", rootCmd.PersistentFlags().Lookup("driver")); err != nil {
panic(err)
}
err = viper.BindPFlag("public", rootCmd.PersistentFlags().Lookup("public"))
if err != nil {
if err := viper.BindPFlag("dsn", rootCmd.PersistentFlags().Lookup("dsn")); err != nil {
panic(err)
}
err = viper.BindPFlag("password-auth", rootCmd.PersistentFlags().Lookup("password-auth"))
if err != nil {
if err := viper.BindPFlag("instance-url", rootCmd.PersistentFlags().Lookup("instance-url")); err != nil {
panic(err)
}

viper.SetEnvPrefix("memos")
viper.AutomaticEnv()
if err := viper.BindEnv("password-auth", "MEMOS_PASSWORD_AUTH"); err != nil {
if err := viper.BindEnv("instance-url", "MEMOS_INSTANCE_URL"); err != nil {
panic(err)
}
}
Expand All @@ -170,11 +149,9 @@ dsn: %s
addr: %s
port: %d
mode: %s
public: %t
password-auth: %t
driver: %s
---
`, profile.Version, profile.Data, profile.DSN, profile.Addr, profile.Port, profile.Mode, profile.Public, profile.PasswordAuth, profile.Driver)
`, profile.Version, profile.Data, profile.DSN, profile.Addr, profile.Port, profile.Mode, profile.Driver)

print(greetingBanner)
if len(profile.Addr) == 0 {
Expand Down
Loading

0 comments on commit 0420405

Please sign in to comment.