Updating database creation

main
Félix MIELCAREK 1 year ago
parent 4a38ce4e7b
commit 4f3062b71c

@ -1,35 +1,34 @@
name: database name: Build and publish the database Docker Image
on: [push]
jobs: on:
database-creation: push:
runs-on: ubuntu-latest branches: ['main']
services:
# Label used to access the service container
postgres:
image: postgres
env: env:
POSTGRES_PASSWORD: postgres REGISTRY: ghcr.io
POSTGRES_DB: big-brother IMAGE_NAME: ${{ github.repository }}
# Set health checks to wait until postgres has started
options: >- jobs:
--health-cmd pg_isready build-and-push-image:
--health-interval 10s runs-on: ubuntu-latest
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install dependencies - name: Set up Docker Buildx
run: pip3 install psycopg2 uses: docker/setup-buildx-action@v1
- name: Connect to PostgreSQL - name: Login to GitHub Container Registry
run: python3 database/db-creation.py uses: docker/login-action@v1
env: with:
POSTGRES_HOST: postgres registry: ghcr.io
POSTGRES_PORT: 5432 username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./database
push: true
tags: ghcr.io/${{ github.repository }}:latest

@ -0,0 +1,8 @@
FROM postgres:latest
COPY database/init_db.py /docker-entrypoint-initdb.d/
RUN apt-get update && apt-get install -y python3 python3-pip && \
pip3 install psycopg2-binary
EXPOSE 5432
Loading…
Cancel
Save