Updating database creation

main
Félix MIELCAREK 11 months ago
parent 4a38ce4e7b
commit 4f3062b71c

@ -1,35 +1,34 @@
name: database name: Build and publish the database Docker Image
on: [push]
on:
push:
branches: ['main']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
database-creation: build-and-push-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: big-brother
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--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: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Connect to PostgreSQL - name: Build and push Docker image
run: python3 database/db-creation.py uses: docker/build-push-action@v2
env: with:
POSTGRES_HOST: postgres context: ./database
POSTGRES_PORT: 5432 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