Skip to content

Commit 257bfde

Browse files
authored
Merge pull request #1 from goto/add-workflow
feat: add build and push workflow
2 parents 9449ab5 + 1be656f commit 257bfde

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
# Run workflow on push events to the main branch
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest # Replace with your preferred runner
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3 # Fetches code from your repository
15+
16+
- name: Login to Docker Hub (using secrets)
17+
uses: docker/login-action@v2 # Official Docker login action
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
22+
- name: Set up Docker Buildx (optional for multi-platform builds)
23+
uses: docker/setup-buildx-action@v3 # Optional for multi-arch builds
24+
25+
- name: Build Docker image (using build args)
26+
uses: docker/build-push-action@v5 # Official Docker build and push action
27+
with:
28+
push: true # Push image to Docker Hub
29+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/postgres-partman:1.0.0 # Replace with your desired tag
30+
context: .
31+
platforms: linux/amd64,linux/arm64
32+
build-args: | # Pass environment variables to build process
33+
POSTGRES_VERSION=15

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG POSTGRES_VERSION
2+
FROM postgres:$POSTGRES_VERSION
3+
4+
RUN apt-get update && apt-get install unzip && apt-get --assume-yes install build-essential && apt-get --assume-yes install postgresql-server-dev-11 && apt-get install -y wget \
5+
&& wget https://github.com/pgpartman/pg_partman/archive/refs/tags/v4.7.4.zip -O 4.7.4.zip \
6+
&& unzip 4.7.4.zip \
7+
&& cd /pg_partman-4.7.4 && pwd && make NO_BGW=1 install
8+
9+
10+
RUN apt-get update && \
11+
apt-get -y install postgresql-15-cron && \
12+
apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+

0 commit comments

Comments
 (0)