Skip to content

Commit

Permalink
Merge pull request #44 from opencloud-eu/docker-builds
Browse files Browse the repository at this point in the history
feat: script for docker builds
  • Loading branch information
kulmann authored Feb 28, 2025
2 parents ec9f32e + 88ae909 commit 3549bf9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dist

# drone CI is in .drone.star, do not let someone accidentally commit a local .drone.yml
.drone.yml
/apps

.env
.idea
Expand Down
27 changes: 27 additions & 0 deletions dev/scripts/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Build the docker image for an application
# Usage: ./build_docker.sh <app_name> <app_version>
# Pre-requisites: App was built before and lies in `/apps/<app_name>`, see `build_app.sh`

APP_NAME="$1"
APP_VERSION="$2"

if [ -z "$APP_NAME" ] || [ -z "$APP_VERSION" ]; then
echo "Error: Please provide the app name and version"
echo "Usage: ./build_docker.sh <app_name> <app_version>"
exit 1
fi

if [ ! -d "./apps/$APP_NAME" ]; then
echo "Error: App not found at ./apps/$APP_NAME"
echo "Please build the app first using ./build_app.sh"
echo "and make sure to run this script from the repository root"
exit 1
fi

docker buildx rm web-extensions-builder || true
docker buildx create --name web-extensions-builder --platform linux/arm64,linux/amd64
docker buildx use web-extensions-builder
docker buildx build --platform linux/arm64,linux/amd64 --output type=docker --file ./docker/Dockerfile --build-arg app_path=apps/$APP_NAME --build-arg app_name=$APP_NAME --tag opencloudeu/web-extensions:$APP_NAME-latest --tag opencloudeu/web-extensions:$APP_NAME-$APP_VERSION --tag quay.io/opencloudeu/web-extensions:$APP_NAME-latest --tag quay.io/opencloudeu/web-extensions:$APP_NAME-$APP_VERSION .
docker buildx rm web-extensions-builder
19 changes: 19 additions & 0 deletions dev/scripts/push_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Push the docker images for an application
# Usage: ./push_docker.sh <app_name> <app_version>
# Pre-requisites: Docker images were built and tagged before, see `build_docker.sh`

APP_NAME="$1"
APP_VERSION="$2"

if [ -z "$APP_NAME" ] || [ -z "$APP_VERSION" ]; then
echo "Error: Please provide the app name and version"
echo "Usage: ./push_docker.sh <app_name> <app_version>"
exit 1
fi

docker push opencloudeu/web-extensions:$APP_NAME-latest
docker push opencloudeu/web-extensions:$APP_NAME-$APP_VERSION
docker push quay.io/opencloudeu/web-extensions:$APP_NAME-latest
docker push quay.io/opencloudeu/web-extensions:$APP_NAME-$APP_VERSION
18 changes: 7 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
FROM opencloud-eu/nginx@sha256:8ca0c90c2f537fef6195ba8f5ebe6d6c00fe0a0c545f25ce8acd418a831a19a4
FROM nginx@sha256:9d6b58feebd2dbd3c56ab5853333d627cc6e281011cfd6050fa4bcf2072c9496

LABEL maintainer="OpenCloud GmbH <info@opencloud.eu>" \
LABEL maintainer="OpenCloud GmbH <devops@opencloud.eu>" \
org.opencontainers.image.title="OpenCloud Web Extensions" \
org.opencontainers.image.description="OpenCloud Web Extensions" \
org.opencontainers.image.vendor="OpenCloud GmbH" \
org.opencontainers.image.authors="OpenCloud GmbH" \
org.opencontainers.image.licenses="AGPL-3.0" \
org.opencontainers.image.documentation="https://github.com/opencloud-eu/web-extensions" \
org.opencontainers.image.url="https://hub.docker.com/r/opencloud-eu/web-extensions" \
org.opencontainers.image.url="https://hub.docker.com/r/opencloudeu/web-extensions" \
org.opencontainers.image.source="https://github.com/opencloud-eu/web-extensions"

ARG app_path
ARG app_name

RUN rm -f /var/lib/nginx/html/*
RUN rm -f /usr/share/nginx/html/*

ADD $app_path /var/lib/nginx/html/$app_name
RUN find /var/lib/nginx/html

EXPOSE 8080

USER nginx
ADD $app_path /usr/share/nginx/html/$app_name
RUN find /usr/share/nginx/html

STOPSIGNAL SIGTERM

CMD ["nginx", "-g", "daemon off;"]
WORKDIR /var/lib/nginx/html
WORKDIR /usr/share/nginx/html

0 comments on commit 3549bf9

Please sign in to comment.