Deploy action with docker-compose file

I have docker-compose.yml that looks like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>version: '3.5'
volumes:
postgres_volume:
networks:
product_catalog_network:
external: true
services:
pg:
build:
context: .
dockerfile: postgres.Dockerfile
image: "<someregistry_url>/postgres:14-alpine"
env_file:
- .env
healthcheck:
test: ["CMD", "pg_isready"]
ports:
- "5432:5432"
networks:
- product_catalog_network
product-catalog-service:
restart: always
build: .
image: "<someregistry_url>/product-catalog-service:latest"
depends_on:
- pg
ports:
- "${GRPC_PORT:-5001}:${GRPC_PORT:-5001}"
- "${HTTP_PORT:-8080}:${HTTP_PORT:-8080}"
- "${SWAGGER_PORT:-8090}:${SWAGGER_PORT:-8090}"
networks:
- product_catalog_network
migrator:
build:
context: .
dockerfile: migration.Dockerfile
image: "<someregistry_url>/migrator:latest"
restart: on-failure
env_file:
- .env
networks:
- product_catalog_network
</code>
<code>version: '3.5' volumes: postgres_volume: networks: product_catalog_network: external: true services: pg: build: context: . dockerfile: postgres.Dockerfile image: "<someregistry_url>/postgres:14-alpine" env_file: - .env healthcheck: test: ["CMD", "pg_isready"] ports: - "5432:5432" networks: - product_catalog_network product-catalog-service: restart: always build: . image: "<someregistry_url>/product-catalog-service:latest" depends_on: - pg ports: - "${GRPC_PORT:-5001}:${GRPC_PORT:-5001}" - "${HTTP_PORT:-8080}:${HTTP_PORT:-8080}" - "${SWAGGER_PORT:-8090}:${SWAGGER_PORT:-8090}" networks: - product_catalog_network migrator: build: context: . dockerfile: migration.Dockerfile image: "<someregistry_url>/migrator:latest" restart: on-failure env_file: - .env networks: - product_catalog_network </code>
version: '3.5'

volumes:
  postgres_volume:

networks:
  product_catalog_network:
    external: true

services:
  pg:
    build:
      context: .
      dockerfile: postgres.Dockerfile
    image: "<someregistry_url>/postgres:14-alpine"
    env_file:
      - .env
    healthcheck:
      test: ["CMD", "pg_isready"]
    ports:
      - "5432:5432"
    networks:
      - product_catalog_network

  product-catalog-service:
    restart: always
    build: .
    image: "<someregistry_url>/product-catalog-service:latest"
    depends_on:
      - pg
    ports:
      - "${GRPC_PORT:-5001}:${GRPC_PORT:-5001}"
      - "${HTTP_PORT:-8080}:${HTTP_PORT:-8080}"
      - "${SWAGGER_PORT:-8090}:${SWAGGER_PORT:-8090}"
    networks:
      - product_catalog_network

  migrator:
    build:
      context: .
      dockerfile: migration.Dockerfile
    image: "<someregistry_url>/migrator:latest"
    restart: on-failure
    env_file:
      - .env
    networks:
      - product_catalog_network

My Dockerfile for product-catalog-service:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FROM golang:1.22-alpine AS builder
RUN apk update && apk upgrade &&
apk add --no-cache git
RUN mkdir /app
WORKDIR /app
ENV GO111MODULE=on
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o product-service ./cmd/main.go
FROM alpine:latest
RUN apk --no-cache add ca-certificates
RUN mkdir /app
WORKDIR /app
COPY .env .
COPY --from=builder /app/product-service .
CMD ["./product-service"]
</code>
<code>FROM golang:1.22-alpine AS builder RUN apk update && apk upgrade && apk add --no-cache git RUN mkdir /app WORKDIR /app ENV GO111MODULE=on COPY . . RUN go mod download RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o product-service ./cmd/main.go FROM alpine:latest RUN apk --no-cache add ca-certificates RUN mkdir /app WORKDIR /app COPY .env . COPY --from=builder /app/product-service . CMD ["./product-service"] </code>
FROM golang:1.22-alpine AS builder

RUN apk update && apk upgrade && 
    apk add --no-cache git

RUN mkdir /app
WORKDIR /app

ENV GO111MODULE=on

COPY . .

RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o product-service ./cmd/main.go

FROM alpine:latest

RUN apk --no-cache add ca-certificates

RUN mkdir /app
WORKDIR /app

COPY .env .

COPY --from=builder /app/product-service .

CMD ["./product-service"]

My migration.Dockerfile:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FROM alpine:3.13
RUN apk update &&
apk upgrade &&
apk add bash &&
rm -rf /var/cache/apk/*
ADD https://github.com/pressly/goose/releases/download/v3.14.0/goose_linux_x86_64 /bin/goose
RUN chmod +x /bin/goose
WORKDIR /root
ADD migrations/*.sql migrations/
ADD migration.sh .
ADD .env .
RUN chmod +x migration.sh
ENTRYPOINT ["bash", "migration.sh"]
</code>
<code>FROM alpine:3.13 RUN apk update && apk upgrade && apk add bash && rm -rf /var/cache/apk/* ADD https://github.com/pressly/goose/releases/download/v3.14.0/goose_linux_x86_64 /bin/goose RUN chmod +x /bin/goose WORKDIR /root ADD migrations/*.sql migrations/ ADD migration.sh . ADD .env . RUN chmod +x migration.sh ENTRYPOINT ["bash", "migration.sh"] </code>
FROM alpine:3.13

RUN apk update && 
    apk upgrade && 
    apk add bash && 
    rm -rf /var/cache/apk/*

ADD https://github.com/pressly/goose/releases/download/v3.14.0/goose_linux_x86_64 /bin/goose
RUN chmod +x /bin/goose

WORKDIR /root

ADD migrations/*.sql migrations/
ADD migration.sh .
ADD .env .

RUN chmod +x migration.sh

ENTRYPOINT ["bash", "migration.sh"]

My postgres.Dockerfile:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FROM postgres:14-alpine
EXPOSE 5432
USER postgres
</code>
<code>FROM postgres:14-alpine EXPOSE 5432 USER postgres </code>
FROM postgres:14-alpine
    
EXPOSE 5432

USER postgres

Now I need to build all this docker images and push them to my registry. I’m doing it like this with GitHub Actions:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>name: Go
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
image-build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: ${{ secrets.REGISTRY_URL }}
- name: Build and push Docker images
run: |
echo "${{ secrets.ENV_DEVELOPMENT }}" > .env
docker-compose build
docker-compose push
</code>
<code>name: Go on: push: branches: [ main, master ] pull_request: branches: [ main, master ] jobs: image-build-and-push: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Log in to Docker Registry uses: docker/login-action@v2 with: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} registry: ${{ secrets.REGISTRY_URL }} - name: Build and push Docker images run: | echo "${{ secrets.ENV_DEVELOPMENT }}" > .env docker-compose build docker-compose push </code>
name: Go

on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]

jobs:
  image-build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Log in to Docker Registry
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.REGISTRY_USERNAME }}
          password: ${{ secrets.REGISTRY_PASSWORD }}
          registry: ${{ secrets.REGISTRY_URL }}

      - name: Build and push Docker images
        run: |
          echo "${{ secrets.ENV_DEVELOPMENT }}" > .env
          docker-compose build
          docker-compose push

After that I need to deploy all my docker images to the remote host. I need to extract them from the registry and run them all. How should I do this? Do I have to manually pull all the images from the registry and run them individually via docker run? Or should I clone my repository with docker-compose.yml and do docker compose pull, docker compose build and docker compose up -d through it already? Or is there some other option that is more preferable?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật