GitHub actions and Docker-compose push to ghcr.io

Viewed 1035

I am trying to push a docker-compose.yml to the docker repository from github. Unfortunately without success so far. Attached my docker-compose.yml and my github.actions

Here are my docker-compose.yml


volumes:
  keycloak_postgres_data: {}

services:
  postgres-keycloak:
      image: postgres:10-alpine
      container_name: postgres
      volumes:
        - keycloak_postgres_data:/var/lib/postgresql/data
      environment:
        POSTGRES_DB: keycloak
        POSTGRES_USER: keycloak
        POSTGRES_PASSWORD: password
        
  keycloak:
      image: jboss/keycloak:latest
      environment:
        DB_VENDOR: POSTGRES
        DB_ADDR: postgres
        DB_DATABASE: keycloak
        DB_USER: keycloak
        DB_PASSWORD: password
        KEYCLOAK_USER: admin
        KEYCLOAK_PASSWORD: testing
      ports:
        - 8080:8080
      volumes:
        - ./themes/upspot_new:/opt/jboss/keycloak/themes/upspot
      depends_on:
        - postgres-keycloak

This is my github-action

name: Docker

on:
  push:
    # Publish `main` as Docker `latest` image.
    branches:
      - main

    # Publish `v1.2.3` tags as releases.
    tags:
      - v*

  # Run tests for any PRs.
  pull_request:

env:
  # TODO: Change variable to your image's name.
  IMAGE_NAME: image

jobs:
  # Push image to GitHub Packages.
  # See also https://docs.docker.com/docker-hub/builds/
  push:
    # Ensure test job passes before pushing image.
    runs-on: ubuntu-latest
    if: github.event_name == 'push'

    steps:
      - uses: actions/checkout@v2

      - name: Build image
        run: docker-compose build

      - name: Log into registry
        run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

      - name: Push image
        run: docker-compose push

Can anyone help me to push it into the Image-Repository? Thanks :)

1 Answers

Which repository do you want it pushed; artifacts in github and/or Dockerhub? This works for me using a compose.yaml file as the compose file etc.

- name: Build Compose Images
  run: docker compose -f compose.yaml build
  
- name: Push image to Container Registry
  run: docker compose -f compose.yaml push
Related