Skip to content

Commit

Permalink
feat: upgrade to pgmodeler 0.9.4 (#72)
Browse files Browse the repository at this point in the history
* feat: upgrade to pgmodeler 0.9.4

* fix: keep paal commented out until fixed

* chore: use buildkit in circleci

* chore: install hadolint with brew in circleci

* chore: clean up LABELS in dockerfile

* fix: eval brew before lint

* chore: clean up github actions workflow
  • Loading branch information
artis3n authored Jan 7, 2022
1 parent 7598c0b commit c7dff59
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 40 deletions.
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
machine:
# https://circleci.com/docs/2.0/configuration-reference/#available-machine-images
image: ubuntu-2004:202104-01
image: ubuntu-2004:202111-02
steps:
- checkout
- run: git submodule sync
Expand All @@ -17,14 +17,16 @@ jobs:
sudo apt-get install build-essential
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
brew install dive
brew install dive hadolint
curl -fsSL https://goss.rocks/install | sudo sh
- run:
name: Build the image
command: make build-ci
command: DOCKER_BUILDKIT=1 make build-ci
- run:
name: Lint
command: make lint
command: |
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
make lint
- run:
name: Goss tests
command: |
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.github
.circleci
.gitmodules
.idea
.hadolint.yaml
.dive-ci
.pre-commit-config.yaml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
submodules: true

- name: Lint Dockerfile
uses: brpaz/hadolint-action@v1.5.0
uses: hadolint/hadolint-action@v1.5.0
19 changes: 4 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,12 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2.1.7
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_PAT }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
Expand All @@ -52,12 +44,9 @@ jobs:
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
--progress plain
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
env:
DOCKER_BUILDKIT: 1
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "pgmodeler"]
path = pgmodeler
url = git@github.com:pgmodeler/pgmodeler.git
url = https://github.com/pgmodeler/pgmodeler.git

[submodule "plugins"]
path = plugins
Expand Down
25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Cannot use alpine because it uses musl instead of glibc and musl doesn't have "backtrace"
# https://github.com/openalpr/openalpr/issues/566#issuecomment-348205549
FROM ubuntu:20.10 as compiler
FROM ubuntu:21.04 as compiler

ARG INSTALLATION_ROOT=/app
ARG QMAKE_PATH=/usr/bin/qmake
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
# qt5-default = qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
&& apt-get -y install --no-install-recommends \
build-essential \
ca-certificates \
git \
libboost-dev \
libpq-dev \
libqt5svg5-dev \
libxml2 \
libxml2-dev \
pkg-config \
qt5-default \
qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools \
qttools5-dev \
# Slim down layer size
# Not strictly necessary since this is a multi-stage build but hadolint would complain
Expand All @@ -33,10 +35,10 @@ COPY ./plugins /pgmodeler/plugins
# https://github.com/pgmodeler/plugins/issues/16
#
# Configure the SQL-join graphical query builder plugin
# WORKDIR /pgmodeler/plugins/graphicalquerybuilder
# RUN ./setup.sh paal \
# && sed -i.bak s/GQB_JOIN_SOLVER=\"n\"/GQB_JOIN_SOLVER=\"y\"/ graphicalquerybuilder.conf \
# && sed -i.bak s/BOOST_INSTALLED=\"n\"/BOOST_INSTALLED=\"y\"/ graphicalquerybuilder.conf
#WORKDIR /pgmodeler/plugins/graphicalquerybuilder
#RUN ./setup.sh paal \
# && sed -i.bak s/GQB_JOIN_SOLVER=\"n\"/GQB_JOIN_SOLVER=\"y\"/ graphicalquerybuilder.conf \
# && sed -i.bak s/BOOST_INSTALLED=\"n\"/BOOST_INSTALLED=\"y\"/ graphicalquerybuilder.conf

WORKDIR /pgmodeler
RUN mkdir /app \
Expand All @@ -45,7 +47,9 @@ RUN mkdir /app \
# Configure qmake for compilation
&& "$QMAKE_PATH" -version \
&& pkg-config libpq --cflags --libs \
&& "$QMAKE_PATH" -r CONFIG+=release \
&& "$QMAKE_PATH" -r \
# CONFIG+=INTERACTIVE_QMAKE \
CONFIG+=release \
PREFIX="$INSTALLATION_ROOT" \
BINDIR="$INSTALLATION_ROOT" \
PRIVATEBINDIR="$INSTALLATION_ROOT" \
Expand All @@ -56,19 +60,18 @@ RUN mkdir /app \
&& make install

# Now that the image is compiled, we can remove most of the image size bloat
FROM ubuntu:20.10 as app
LABEL name="artis3n/pgmodeler"
LABEL version="1.4.0"
FROM ubuntu:21.04 as app
LABEL maintainer="Artis3n <dev@artis3nal.com>"

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
# qt5-default = qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
&& apt-get -y install --no-install-recommends \
libpq-dev \
libqt5svg5-dev \
libxml2 \
qt5-default \
qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools \
# Slim down layer size
&& apt-get autoremove -y \
&& apt-get autoclean -y \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ install:

.PHONY: lint
lint:
docker run --rm -i hadolint/hadolint hadolint --ignore DL3008 - < Dockerfile
hadolint --ignore DL3008 Dockerfile

.PHONY: size
size:
Expand All @@ -27,11 +27,11 @@ test-edit:

.PHONY: build
build:
DOCKER_BUILDKIT=1 docker build . -t artis3n/pgmodeler:$${TAG:-test}
docker build . -t artis3n/pgmodeler:$${TAG:-test}

.PHONY: build-ci
build-ci:
DOCKER_BUILDKIT=1 docker build --progress plain . -t artis3n/pgmodeler:$${TAG:-test}
docker build --progress plain . -t artis3n/pgmodeler:$${TAG:-test}

.PHONY: run
run:
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

Docker image wrapping [pgmodeler/pgmodeler][pgmodeler repo]. Unlike other containers I've seen for this project, this container is **_secure by default_**. There is no `--privileged` or any capabilities passed to the container. There is a non-root user. You don't over-expose your Xserver. You get the graphical interface for PGModeler and can save project files to a specified volume for persistence with peace of mind. Best of all, this container weighs just under 400 MB!

Download from GitHub Container Registry or Docker Hub:
Download from GitHub Container Registry:

```bash
docker pull ghcr.io/artis3n/pgmodeler:latest
docker pull artis3n/pgmodeler:latest
```

I [wrote an article][blog article] explaining in detail how I set up this container to be secure.
Expand Down Expand Up @@ -59,7 +58,7 @@ For OSX hosts, you have to install a Linux-compatible X11 server. The most commo

The steps are:

1. `brew cask install xquartz`
1. `brew install xauth; brew install --cask xquartz`
1. `open -a XQuartz`
1. Ensure XQuartz is running whenever you want to run this image.
1. XQuartz preferences -> Security -> check "Allow connections from network clients"
Expand Down
2 changes: 1 addition & 1 deletion pgmodeler
Submodule pgmodeler updated 1402 files
2 changes: 1 addition & 1 deletion plugins

0 comments on commit c7dff59

Please sign in to comment.