diff --git a/docker/Dockerfile b/docker/Dockerfile index 6f66bd9..b5af08e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,22 @@ -# FROM ghcr.io/linuxcontainers/debian-slim:latest - -FROM lovasoa/sqlpage +FROM ghcr.io/linuxcontainers/debian-slim:latest COPY --from=ghcr.io/amacneil/dbmate /usr/local/bin/dbmate /usr/local/bin/dbmate +COPY --from=lovasoa/sqlpage:latest /usr/local/bin/sqlpage /usr/local/bin/sqlpage +COPY --from=lovasoa/sqlpage:latest /lib/libgcc_s.so.1 /lib/libgcc_s.so.1 WORKDIR /app + +ENV SQLPAGE_WEB_ROOT=/app +ENV SQLPAGE_CONFIGURATION_DIRECTORY=/etc/sqlpage + +RUN addgroup --gid 1000 --system index_user && \ + adduser --uid 1000 --system --no-create-home --ingroup index_user index_user && \ + mkdir -p /etc/sqlpage && \ + touch /etc/sqlpage/sqlpage.db && \ + chown -R index_user:index_user /etc/sqlpage/sqlpage.db + +COPY --chown=index_user:index_user ./src /app + +USER index_user + +CMD /usr/local/bin/sqlpage diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 87fa582..799130e 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -2,13 +2,17 @@ services: index: image: alecodes/index:latest pull_policy: build - user: 1000:1000 build: context: .. dockerfile: ./docker/Dockerfile + develop: + watch: + - action: sync + path: ../src + target: /app + ports: + - 3000:8080 env_file: ../.env - volumes: - - ../src:/app db: image: postgres:17 diff --git a/src/db/migrations/20250205190533_create_sources_table.sql b/src/db/migrations/20250205190533_create_sources_table.sql index a2239ac..843efc1 100644 --- a/src/db/migrations/20250205190533_create_sources_table.sql +++ b/src/db/migrations/20250205190533_create_sources_table.sql @@ -1,5 +1,13 @@ -- migrate:up - +CREATE TABLE public.sources ( + id serial PRIMARY KEY, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone + ); -- migrate:down - +DROP TABLE public.sources; diff --git a/src/index.sql b/src/index.sql new file mode 100644 index 0000000..3886b29 --- /dev/null +++ b/src/index.sql @@ -0,0 +1,6 @@ +SELECT 'list' AS component, + 'Popular websites TESTOOO' AS title; + +SELECT 'Hello' AS title, + 'world' AS description, + 'https://wikipedia.org' AS link;