chore: add build workflow
Some checks failed
Publish image / create-docker-images (push) Successful in 30s
Publish image / deploy (push) Successful in 12s
Publish image / rebase (push) Failing after 8s

This commit is contained in:
Alexander Navarro 2025-02-07 19:46:16 -03:00
parent 6288969c4d
commit 0a70046480
4 changed files with 153 additions and 2 deletions

View file

@ -1,12 +1,16 @@
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:main /usr/local/bin/sqlpage /usr/local/bin/sqlpage
COPY --from=ghcr.io/amacneil/dbmate:main /usr/local/bin/dbmate /usr/local/bin/dbmate
COPY --from=lovasoa/sqlpage /usr/local/bin/sqlpage /usr/local/bin/sqlpage
WORKDIR /app
ENV SQLPAGE_WEB_ROOT=/app
ENV SQLPAGE_CONFIGURATION_DIRECTORY=/app/sqlpage
ENV DB_DRIVER=
ENV DB_USER=
ENV DB_NAME=
ENV DB_PASSWORD_FILE=
RUN addgroup --gid 1000 --system index_user && \
adduser --uid 1000 --system --no-create-home --ingroup index_user index_user && \
@ -15,7 +19,12 @@ RUN addgroup --gid 1000 --system index_user && \
chown -R index_user:index_user /etc/sqlpage/sqlpage.db
COPY --chown=index_user:index_user ./src /app
COPY --chown=index_user:index_user ./docker/entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod a+x /usr/bin/entrypoint.sh
USER index_user
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD /usr/local/bin/sqlpage

63
docker/docker-stack.yaml Normal file
View file

@ -0,0 +1,63 @@
services:
index:
image: git.alecodes.page/alecodes/index:${GITHUB_SHA:-latest}
networks:
- reverse_proxy
- default
secrets:
- index_db_pass
environment:
SQLPAGE_WEB_ROOT: /app
DB_DRIVER: postgres
DB_HOST: task.db
DB_USER: index
DB_NAME: index
DB_PASSWORD_FILE: /run/secrets/index_db_pass
deploy:
rollback_config:
failure_action: continue
update_config:
delay: 2s
failure_action: rollback
order: start-first
placement:
constraints:
- node.labels.services_kind==projects
labels:
- traefik.enable=true
- traefik.http.routers.index.rule=Host(`alecodes.page`)
- traefik.http.services.index.loadbalancer.server.port=3000
db:
image: postgres:17
networks:
- default
secrets:
- index_db_pass
environment:
POSTGRES_USER: index
POSTGRES_DB: index
POSTGRES_PASSWORD_FILE: /run/secrets/index_db_pass
volumes:
- db_data:/var/lib/postgresql/data
deploy:
rollback_config:
failure_action: continue
update_config:
delay: 2s
failure_action: rollback
order: start-first
placement:
constraints:
- node.labels.services_kind==projects
volumes:
db_data:
networks:
reverse_proxy:
external: true
secrets:
index_db_pass:
external: true

13
docker/entrypoint.sh Normal file
View file

@ -0,0 +1,13 @@
#!/bin/sh
if [ -e $DB_PASSWORD_FILE ]; then
DB_PASSWORD=$(cat $DB_PASSWORD_FILE)
fi
export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:5432/${DB_DB}?sslmode=disable"
echo "Connecting to DATABASE = postgres://${DB_USER}:******@${DB_HOST}:5432/${DB_DB}?sslmode=disable"
dbmate migrate --wait
exec "$@"