Skip to content

Commit 4e36a53

Browse files
committed
FEATURE/queries-via-UI
1 parent 5f36f26 commit 4e36a53

File tree

22 files changed

+851
-196
lines changed

22 files changed

+851
-196
lines changed

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text=auto
2+
*.sh text eol=lf
3+
*.js text eol=lf
4+
*.ts text eol=lf
5+
*.php text eol=lf
6+
*.yml text eol=lf
7+
*.yaml text eol=lf
8+
*.json text eol=lf

.gitignore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
postgresus_data/
2-
postgresus-data/
3-
.env
4-
pgdata/
5-
docker-compose.yml
6-
node_modules/
1+
postgresus_data/
2+
postgresus-data/
3+
.env
4+
pgdata/
5+
docker-compose.yml
6+
node_modules/
77
.idea

Dockerfile

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,30 @@ COPY frontend/ ./
1313

1414
# Copy .env file (with fallback to .env.production.example)
1515
RUN if [ ! -f .env ]; then \
16-
if [ -f .env.production.example ]; then \
17-
cp .env.production.example .env; \
18-
fi; \
19-
fi
16+
if [ -f .env.production.example ]; then \
17+
cp .env.production.example .env; \
18+
fi; \
19+
fi
2020

2121
RUN npm run build
2222

2323
# ========= BUILD BACKEND =========
24+
# Backend build stage
2425
FROM --platform=$BUILDPLATFORM golang:1.23.3 AS backend-build
2526

26-
# Install Go public tools needed in runtime
27-
RUN curl -fsSL https://raw.githubusercontent.com/pressly/goose/master/install.sh | sh
27+
# Make TARGET args available early so tools built here match the final image arch
28+
ARG TARGETOS
29+
ARG TARGETARCH
30+
31+
# Install Go public tools needed in runtime. Use `go build` for goose so the
32+
# binary is compiled for the target architecture instead of downloading a
33+
# prebuilt binary which may have the wrong architecture (causes exec format
34+
# errors on ARM).
35+
RUN git clone --depth 1 --branch v3.24.3 https://github.com/pressly/goose.git /tmp/goose && \
36+
cd /tmp/goose/cmd/goose && \
37+
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
38+
go build -o /usr/local/bin/goose . && \
39+
rm -rf /tmp/goose
2840
RUN go install github.com/swaggo/swag/cmd/[email protected]
2941

3042
# Set working directory
@@ -49,35 +61,38 @@ ARG TARGETOS
4961
ARG TARGETARCH
5062
ARG TARGETVARIANT
5163
RUN CGO_ENABLED=0 \
52-
GOOS=$TARGETOS \
53-
GOARCH=$TARGETARCH \
54-
go build -o /app/main ./cmd/main.go
64+
GOOS=$TARGETOS \
65+
GOARCH=$TARGETARCH \
66+
go build -o /app/main ./cmd/main.go
5567

5668

5769
# ========= RUNTIME =========
58-
FROM --platform=$TARGETPLATFORM debian:bookworm-slim
70+
FROM debian:bookworm-slim
5971

6072
# Add version metadata to runtime image
6173
ARG APP_VERSION=dev
6274
LABEL org.opencontainers.image.version=$APP_VERSION
6375
ENV APP_VERSION=$APP_VERSION
6476

77+
# Set production mode for Docker containers
78+
ENV ENV_MODE=production
79+
6580
# Install PostgreSQL server and client tools (versions 13-17)
6681
RUN apt-get update && apt-get install -y --no-install-recommends \
67-
wget ca-certificates gnupg lsb-release sudo gosu && \
68-
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
69-
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
70-
> /etc/apt/sources.list.d/pgdg.list && \
71-
apt-get update && \
72-
apt-get install -y --no-install-recommends \
73-
postgresql-17 postgresql-client-13 postgresql-client-14 postgresql-client-15 \
74-
postgresql-client-16 postgresql-client-17 && \
75-
rm -rf /var/lib/apt/lists/*
82+
wget ca-certificates gnupg lsb-release sudo gosu && \
83+
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
84+
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
85+
> /etc/apt/sources.list.d/pgdg.list && \
86+
apt-get update && \
87+
apt-get install -y --no-install-recommends \
88+
postgresql-17 postgresql-client-13 postgresql-client-14 postgresql-client-15 \
89+
postgresql-client-16 postgresql-client-17 && \
90+
rm -rf /var/lib/apt/lists/*
7691

7792
# Create postgres user and set up directories
7893
RUN useradd -m -s /bin/bash postgres || true && \
79-
mkdir -p /postgresus-data/pgdata && \
80-
chown -R postgres:postgres /postgresus-data/pgdata
94+
mkdir -p /postgresus-data/pgdata && \
95+
chown -R postgres:postgres /postgresus-data/pgdata
8196

8297
WORKDIR /app
8398

@@ -96,10 +111,10 @@ COPY --from=backend-build /app/ui/build ./ui/build
96111
# Copy .env file (with fallback to .env.production.example)
97112
COPY backend/.env* /app/
98113
RUN if [ ! -f /app/.env ]; then \
99-
if [ -f /app/.env.production.example ]; then \
100-
cp /app/.env.production.example /app/.env; \
101-
fi; \
102-
fi
114+
if [ -f /app/.env.production.example ]; then \
115+
cp /app/.env.production.example /app/.env; \
116+
fi; \
117+
fi
103118

104119
# Create startup script
105120
COPY <<EOF /app/start.sh
@@ -151,8 +166,10 @@ done
151166
echo "Setting up database and user..."
152167
gosu postgres \$PG_BIN/psql -p 5437 -h localhost -d postgres << 'SQL'
153168
ALTER USER postgres WITH PASSWORD 'Q1234567';
154-
CREATE DATABASE "postgresus" OWNER postgres;
155-
\q
169+
SELECT 'CREATE DATABASE postgresus OWNER postgres'
170+
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'postgresus')
171+
\\gexec
172+
\\q
156173
SQL
157174

158175
# Start the main application
@@ -168,4 +185,4 @@ EXPOSE 4005
168185
VOLUME ["/postgresus-data"]
169186

170187
ENTRYPOINT ["/app/start.sh"]
171-
CMD []
188+
CMD []

backend/.env.development.example

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
# docker-compose.yml
2-
DEV_DB_NAME=postgresus
3-
DEV_DB_USERNAME=postgres
4-
DEV_DB_PASSWORD=Q1234567
5-
#app
6-
ENV_MODE=development
7-
# db
8-
DATABASE_DSN=host=dev-db user=postgres password=Q1234567 dbname=postgresus port=5437 sslmode=disable
9-
DATABASE_URL=postgres://postgres:Q1234567@dev-db:5437/postgresus?sslmode=disable
10-
# migrations
11-
GOOSE_DRIVER=postgres
12-
GOOSE_DBSTRING=postgres://postgres:Q1234567@dev-db:5437/postgresus?sslmode=disable
13-
GOOSE_MIGRATION_DIR=./migrations
14-
# testing
15-
# to get Google Drive env variables: add storage in UI and copy data from added storage here
16-
TEST_GOOGLE_DRIVE_CLIENT_ID=
17-
TEST_GOOGLE_DRIVE_CLIENT_SECRET=
18-
TEST_GOOGLE_DRIVE_TOKEN_JSON="{\"access_token\":\"ya29..."
19-
# testing DBs
20-
TEST_POSTGRES_13_PORT=5001
21-
TEST_POSTGRES_14_PORT=5002
22-
TEST_POSTGRES_15_PORT=5003
23-
TEST_POSTGRES_16_PORT=5004
24-
TEST_POSTGRES_17_PORT=5005
25-
# testing S3
26-
TEST_MINIO_PORT=9000
27-
TEST_MINIO_CONSOLE_PORT=9001
28-
# testing NAS
1+
# docker-compose.yml
2+
DEV_DB_NAME=postgresus
3+
DEV_DB_USERNAME=postgres
4+
DEV_DB_PASSWORD=Q1234567
5+
#app
6+
ENV_MODE=development
7+
# db
8+
DATABASE_DSN=host=dev-db user=postgres password=Q1234567 dbname=postgresus port=5437 sslmode=disable
9+
DATABASE_URL=postgres://postgres:Q1234567@dev-db:5437/postgresus?sslmode=disable
10+
# migrations
11+
GOOSE_DRIVER=postgres
12+
GOOSE_DBSTRING=postgres://postgres:Q1234567@dev-db:5437/postgresus?sslmode=disable
13+
GOOSE_MIGRATION_DIR=./migrations
14+
# testing
15+
# to get Google Drive env variables: add storage in UI and copy data from added storage here
16+
TEST_GOOGLE_DRIVE_CLIENT_ID=
17+
TEST_GOOGLE_DRIVE_CLIENT_SECRET=
18+
TEST_GOOGLE_DRIVE_TOKEN_JSON="{\"access_token\":\"ya29..."
19+
# testing DBs
20+
TEST_POSTGRES_13_PORT=5001
21+
TEST_POSTGRES_14_PORT=5002
22+
TEST_POSTGRES_15_PORT=5003
23+
TEST_POSTGRES_16_PORT=5004
24+
TEST_POSTGRES_17_PORT=5005
25+
# testing S3
26+
TEST_MINIO_PORT=9000
27+
TEST_MINIO_CONSOLE_PORT=9001
28+
# testing NAS
2929
TEST_NAS_PORT=5006

backend/.env.production.example

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# docker-compose.yml
2-
DEV_DB_NAME=postgresus
3-
DEV_DB_USERNAME=postgres
4-
DEV_DB_PASSWORD=Q1234567
5-
#app
6-
ENV_MODE=production
7-
# db
8-
DATABASE_DSN=host=localhost user=postgres password=Q1234567 dbname=postgresus port=5437 sslmode=disable
9-
DATABASE_URL=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
10-
# migrations
11-
GOOSE_DRIVER=postgres
12-
GOOSE_DBSTRING=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
1+
# docker-compose.yml
2+
DEV_DB_NAME=postgresus
3+
DEV_DB_USERNAME=postgres
4+
DEV_DB_PASSWORD=Q1234567
5+
#app
6+
ENV_MODE=production
7+
# db
8+
DATABASE_DSN=host=localhost user=postgres password=Q1234567 dbname=postgresus port=5437 sslmode=disable
9+
DATABASE_URL=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
10+
# migrations
11+
GOOSE_DRIVER=postgres
12+
GOOSE_DBSTRING=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
1313
GOOSE_MIGRATION_DIR=./migrations

backend/.gitignore

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
main
2-
.env
3-
docker-compose.yml
4-
pgdata
5-
pgdata_test/
6-
main.exe
7-
swagger/
8-
swagger/*
9-
swagger/docs.go
10-
swagger/swagger.json
11-
swagger/swagger.yaml
12-
postgresus-backend.exe
13-
ui/build/*
14-
pgdata-for-restore/
1+
main
2+
.env
3+
docker-compose.yml
4+
pgdata
5+
pgdata_test/
6+
main.exe
7+
swagger/
8+
swagger/*
9+
swagger/docs.go
10+
swagger/swagger.json
11+
swagger/swagger.yaml
12+
postgresus-backend.exe
13+
ui/build/*
14+
pgdata-for-restore/
1515
temp/

backend/.golangci.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
version: "2"
2-
3-
run:
4-
timeout: 1m
5-
tests: false
6-
concurrency: 4
7-
8-
linters:
9-
default: standard
10-
11-
settings:
12-
errcheck:
13-
check-type-assertions: true
14-
15-
formatters:
16-
enable:
17-
- gofmt
18-
- golines
19-
- goimports
1+
version: "2"
2+
3+
run:
4+
timeout: 1m
5+
tests: false
6+
concurrency: 4
7+
8+
linters:
9+
default: standard
10+
11+
settings:
12+
errcheck:
13+
check-type-assertions: true
14+
15+
formatters:
16+
enable:
17+
- gofmt
18+
- golines
19+
- goimports

0 commit comments

Comments
 (0)