Skip to content

Commit

Permalink
mongo ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
smalho01 committed Dec 23, 2024
1 parent f0722be commit 9a23e01
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/mongo-docker-cd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Mongo Development Docker Image CD

on:
push:
branches: [ dev ]
workflow_dispatch:

jobs:
mongo-docker-cd:
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true

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

- name: Docker meta data
id: docker-meta-data
uses: docker/metadata-action@v4
with:
images: codexrems/mongo
flavor: latest=false

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push mongo Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile.mongo
push: true
tags: codexrems/mongo:experimental
labels: ${{ steps.docker-meta-data.outputs.labels }}

44 changes: 44 additions & 0 deletions .github/mongo-docker-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Mongo Docker Image CD

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
mongo-docker-cd:
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta data
id: docker-meta-data
uses: docker/metadata-action@v4
with:
images: codexrems/mongo
flavor: latest=false

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push Mongo Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile.mongo
push: true
tags: codexrems/mongo:latest
labels: ${{ steps.docker-meta-data.outputs.labels }}


19 changes: 19 additions & 0 deletions .github/mongo-docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Mongo Docker Image CI

on:
pull_request:
branches: [ main, dev ]
workflow_dispatch:

jobs:
docker-ci:
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v2
with:
submodules: true

- name: Test Server Docker image Builds
run: docker build -f Dockerfile.mongo .
42 changes: 42 additions & 0 deletions .github/mongo-docker-tag-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Mongo Docker Tagged Image CD
on:
workflow_dispatch:
push:
tags:
- '*'

jobs:
docker:
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true

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

- name: Docker meta data
id: docker-meta-data
uses: docker/metadata-action@v4
with:
images: codexrems/mongo
flavor: latest=false

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
file: Dockerfile.mongo
tags: ${{ steps.docker-meta-data.outputs.tags }}
labels: ${{ steps.docker-meta-data.outputs.labels }}
5 changes: 5 additions & 0 deletions Dockerfile.mongo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mongo:latest

ENV MONGO_INITDB_ROOT_USERNAME=mongo-user
ENV MONGO_INITDB_ROOT_PASSWORD=mongo-password
COPY ./mongo-init.js /docker-entrypoint-initdb.d/mongo-init.js

0 comments on commit 9a23e01

Please sign in to comment.