init commit

This commit is contained in:
2025-11-30 13:01:24 -05:00
parent f4596a372d
commit 29355260ed
607 changed files with 136371 additions and 234 deletions

31
scripts/Dockerfile Normal file
View File

@@ -0,0 +1,31 @@
FROM golang:1.24-alpine AS backend
WORKDIR /backend-build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Please build frontend first, so that the static files are available.
# Refer to `pnpm release` in package.json for the build command.
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -ldflags="-s -w" -o memos ./bin/memos/main.go
# Make workspace with above generated files.
FROM alpine: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/
COPY ./scripts/entrypoint.sh /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"
ENV MEMOS_PORT="5230"
ENTRYPOINT ["./entrypoint.sh", "./memos"]

29
scripts/build.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
# Exit when any command fails
set -e
# Get the script directory and change to the project root
cd "$(dirname "$0")/../"
# Detect the operating system
OS=$(uname -s)
# Set output file name based on the OS
if [[ "$OS" == *"CYGWIN"* || "$OS" == *"MINGW"* || "$OS" == *"MSYS"* ]]; then
OUTPUT="./build/memos.exe"
else
OUTPUT="./build/memos"
fi
echo "Building for $OS..."
# Build the executable
go build -o "$OUTPUT" ./bin/memos/main.go
# Output the success message
echo "Build successful!"
# Output the command to run
echo "To run the application, execute the following command:"
echo "$OUTPUT --mode dev"

8
scripts/compose.yaml Normal file
View File

@@ -0,0 +1,8 @@
services:
memos:
image: neosmemo/memos:latest
container_name: memos
volumes:
- ~/.memos/:/var/opt/memos
ports:
- 5230:5230

27
scripts/entrypoint.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env sh
file_env() {
var="$1"
fileVar="${var}_FILE"
val_var="$(printenv "$var")"
val_fileVar="$(printenv "$fileVar")"
if [ -n "$val_var" ] && [ -n "$val_fileVar" ]; then
echo "error: both $var and $fileVar are set (but are exclusive)" >&2
exit 1
fi
if [ -n "$val_var" ]; then
val="$val_var"
elif [ -n "$val_fileVar" ]; then
val="$(cat "$val_fileVar")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env "MEMOS_DSN"
exec "$@"