Skip to content

Commit

Permalink
PORT-5453 Create centralized dockerfile (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
yairsimantov20 authored Dec 17, 2023
1 parent c5e6f4d commit 29c1d18
Show file tree
Hide file tree
Showing 38 changed files with 145 additions and 1,342 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ jobs:
if [ "$MANIFEST" = "200" ]; then
echo "Image already exists in $repository: port-ocean-$type:$version"
else
dockerfile_path=integrations/_infra/Dockerfile
if test -e $folder/../Dockerfile; then
dockerfile_path=$folder/../Dockerfile
fi
# Check if the 'version' variable contains any character other than digits and "."
if [[ ! "$version" =~ ^[0-9.]+$ ]]; then
# If 'version' contains non-numeric and non-dot characters, skip building 'latest' tag
echo "Version contains non-numeric characters. Building without 'latest' tag."
docker build -t "ghcr.io/port-labs/port-ocean-$type:$version" "$folder/.."
docker buildx build -f $dockerfile_path -t "ghcr.io/port-labs/port-ocean-$type:$version" --build-arg="BUILD_CONTEXT=$folder/.." .
else
# If 'version' contains only digits and dots, build with both 'latest' and version tags
docker build -t "ghcr.io/port-labs/port-ocean-$type:$version" -t "ghcr.io/port-labs/port-ocean-$type:latest" "$folder/.."
docker buildx build -f $dockerfile_path -t "ghcr.io/port-labs/port-ocean-$type:$version" -t "ghcr.io/port-labs/port-ocean-$type:latest" --build-arg="BUILD_CONTEXT=$folder/.." .
fi
docker push "ghcr.io/port-labs/port-ocean-$type" --all-tags
fi
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ run: lint
$(ACTIVATE) && poetry run ocean sail ./integrations/example

new:
$(ACTIVATE) && poetry run ocean new ./integrations
$(ACTIVATE) && poetry run ocean new ./integrations --remove-docker-files

test: lint
$(ACTIVATE) && pytest
Expand Down
7 changes: 7 additions & 0 deletions changelog/PORT-5453.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Added a way to create the integration without the Dockerfile and .dockerignore to use the global Docker files when scaffolding a new integration.






Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM python:3.11-slim-buster

ARG BUILD_CONTEXT
ENV LIBRDKAFKA_VERSION 1.9.2

WORKDIR /app
Expand All @@ -8,8 +9,11 @@ RUN apt update && \
apt install -y wget make g++ libssl-dev autoconf automake libtool curl librdkafka-dev && \
apt-get clean

COPY . /app
COPY ./integrations/_infra/init.sh /app/init.sh
RUN chmod +x /app/init.sh

COPY ./${BUILD_CONTEXT} /app

RUN export POETRY_VIRTUALENVS_CREATE=false && make install/prod && pip cache purge

ENTRYPOINT ocean sail
ENTRYPOINT ./init.sh
94 changes: 94 additions & 0 deletions integrations/_infra/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

# Git
**/.git
**/.gitignore
**/.gitattributes


# CI
**/.codeclimate.yml
**/.travis.yml
**/.taskcluster.yml

# Docker
**/docker-compose.yml
**/Dockerfile
**/.docker
**/.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
**/*.so

# Distribution / packaging
**/.Python
**/env/
**/build/
**/develop-eggs/
**/dist/
**/downloads/
**/eggs/
**/lib/
**/lib64/
**/parts/
**/sdist/
**/var/
**/*.egg-info/
**/.installed.cfg
**/*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
**/*.manifest
**/*.spec

# Installer logs
**/pip-log.txt
**/pip-delete-this-directory.txt

# Unit test / coverage reports
**/htmlcov/
**/.tox/
**/.coverage
**/.cache
**/nosetests.xml
**/coverage.xml

# Translations
**/*.mo
**/*.pot

# Django stuff:
**/*.log

# Sphinx documentation
**/docs/_build/

# PyBuilder
**/target/

# Virtual environment
**/.env
**/.venv/
**/venv/

# PyCharm
**/.idea

# Python mode for VIM
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
**/.vscode/

**/*.md
**/.ruff_cache
**/cahangelog
**/tests
5 changes: 5 additions & 0 deletions integrations/_infra/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if test -e /usr/local/share/ca-certificates/cert.crt; then
update-ca-certificates
fi

ocean sail
94 changes: 0 additions & 94 deletions integrations/argocd/.dockerignore

This file was deleted.

15 changes: 0 additions & 15 deletions integrations/argocd/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions integrations/azure/.dockerignore

This file was deleted.

15 changes: 0 additions & 15 deletions integrations/azure/Dockerfile

This file was deleted.

94 changes: 0 additions & 94 deletions integrations/firehydrant/.dockerignore

This file was deleted.

Loading

0 comments on commit 29c1d18

Please sign in to comment.