Updated dockerfiles & gitlab ci
This commit is contained in:
parent
bf980be6e7
commit
fe8f178b6f
7 changed files with 191 additions and 49 deletions
|
@ -51,39 +51,41 @@ build-debian:
|
||||||
- build/*.deb
|
- build/*.deb
|
||||||
|
|
||||||
# Build the Alpine Docker image
|
# Build the Alpine Docker image
|
||||||
ncc-docker-build:
|
ncc-docker-build-alpine:
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
stage: build-docker
|
stage: build-docker-alpine
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
before_script:
|
before_script:
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
if [[ ! -z "$CI_COMMIT_TAG" ]]; then
|
if [[ "$CI_COMMIT_BRANCH" == "master" ]]; then
|
||||||
|
DOCKER_TAG="latest-alpine"
|
||||||
|
elif [[ ! -z "$CI_COMMIT_TAG" ]]; then
|
||||||
DOCKER_TAG="$CI_COMMIT_TAG-alpine"
|
DOCKER_TAG="$CI_COMMIT_TAG-alpine"
|
||||||
else
|
else
|
||||||
DOCKER_TAG="$CI_COMMIT_REF_SLUG-alpine"
|
DOCKER_TAG="$CI_COMMIT_REF_SLUG-alpine"
|
||||||
fi
|
fi
|
||||||
- docker build -f Dockerfile -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
|
- docker build -f Dockerfile.alpine -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
|
||||||
- docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
|
- docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'dev'
|
- exists:
|
||||||
exists:
|
- Dockerfile.alpine
|
||||||
- Dockerfile
|
|
||||||
|
|
||||||
|
|
||||||
# Build the Debian Docker image
|
# Build the Debian Docker image
|
||||||
ncc-docker-build-debian:
|
ncc-docker-build-debian:
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
stage: build-docker
|
stage: build-docker-debian
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
before_script:
|
before_script:
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
if [[ ! -z "$CI_COMMIT_TAG" ]]; then
|
if [[ "$CI_COMMIT_BRANCH" == "master" ]]; then
|
||||||
|
DOCKER_TAG="latest-debian"
|
||||||
|
elif [[ ! -z "$CI_COMMIT_TAG" ]]; then
|
||||||
DOCKER_TAG="$CI_COMMIT_TAG-debian"
|
DOCKER_TAG="$CI_COMMIT_TAG-debian"
|
||||||
else
|
else
|
||||||
DOCKER_TAG="$CI_COMMIT_REF_SLUG-debian"
|
DOCKER_TAG="$CI_COMMIT_REF_SLUG-debian"
|
||||||
|
@ -91,8 +93,7 @@ ncc-docker-build-debian:
|
||||||
- docker build -f Dockerfile.debian -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
|
- docker build -f Dockerfile.debian -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
|
||||||
- docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
|
- docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'dev'
|
- exists:
|
||||||
exists:
|
|
||||||
- Dockerfile.debian
|
- Dockerfile.debian
|
||||||
|
|
||||||
# Publish the tarball and Debian package to the GitLab Package Registry
|
# Publish the tarball and Debian package to the GitLab Package Registry
|
||||||
|
|
66
Dockerfile.alpine
Normal file
66
Dockerfile.alpine
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# Copyright 2022-2023 Nosial - All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||||
|
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||||
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||||
|
# Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||||
|
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# ncc in Docker
|
||||||
|
#
|
||||||
|
# This image is intended to be used as a base for projects using ncc.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Builder stage: downloads necessary files and serves them on a silver platter.
|
||||||
|
FROM php:8.2-fpm AS builder
|
||||||
|
ENV GENERIC_BUILD_PATH=/tmp/ncc_build
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
# Install some stuff the default image doesn't come with
|
||||||
|
RUN apt-get update -yqq && \
|
||||||
|
apt-get install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||||
|
|
||||||
|
# Download phive and install phab
|
||||||
|
RUN wget -O phive.phar https://phar.io/releases/phive.phar && \
|
||||||
|
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc && \
|
||||||
|
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79 && \
|
||||||
|
gpg --verify phive.phar.asc phive.phar && \
|
||||||
|
rm phive.phar.asc && chmod +x phive.phar && \
|
||||||
|
./phive.phar install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||||
|
|
||||||
|
# Copy the local repository to the image
|
||||||
|
COPY . /tmp/ncc
|
||||||
|
|
||||||
|
# Build ncc
|
||||||
|
RUN cd /tmp/ncc && make redist
|
||||||
|
|
||||||
|
|
||||||
|
# Main stage: Copies build files and installs all dependencies
|
||||||
|
FROM php:8.2-fpm-alpine AS production
|
||||||
|
LABEL maintainer="netkas <netkas@nosial.net>"
|
||||||
|
LABEL description="ncc alpine docker image"
|
||||||
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
||||||
|
|
||||||
|
# Copy downloaded files
|
||||||
|
COPY --from=builder /tmp/ncc_build/. .
|
||||||
|
|
||||||
|
# Install some stuff the default image doesn't come with
|
||||||
|
RUN apk update && \
|
||||||
|
apk add --no-cache git libpq libzip zip make wget gnupg gcc
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
|
||||||
|
install-php-extensions zip xsl
|
||||||
|
|
||||||
|
# Install ncc
|
||||||
|
RUN php INSTALL --auto; cd ../; rm -rf ncc
|
||||||
|
|
||||||
|
# Finalize image
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
|
@ -18,58 +18,49 @@
|
||||||
# This image is intended to be used as a base for projects using ncc.
|
# This image is intended to be used as a base for projects using ncc.
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
|
||||||
# Builder stage: downloads necessary files and serves them on a silver platter.
|
# Builder stage: downloads necessary files and serves them on a silver platter.
|
||||||
#
|
|
||||||
|
|
||||||
FROM php:8.2-fpm AS builder
|
FROM php:8.2-fpm AS builder
|
||||||
|
ENV GENERIC_BUILD_PATH=/tmp/ncc_build
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
|
|
||||||
# Install some stuff the default image doesn't come with
|
# Install some stuff the default image doesn't come with
|
||||||
RUN apt update -yqq; \
|
RUN apt-get update -yqq && \
|
||||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
apt-get install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||||
|
|
||||||
# Download phive and install phab
|
# Download phive and install phab
|
||||||
RUN wget -O phive.phar https://phar.io/releases/phive.phar; \
|
RUN wget -O phive.phar https://phar.io/releases/phive.phar && \
|
||||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc; \
|
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc && \
|
||||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79; \
|
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79 && \
|
||||||
gpg --verify phive.phar.asc phive.phar; \
|
gpg --verify phive.phar.asc phive.phar && \
|
||||||
rm phive.phar.asc; chmod +x phive.phar; ./phive.phar install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
rm phive.phar.asc && chmod +x phive.phar && \
|
||||||
|
./phive.phar install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||||
|
|
||||||
# Copy the local repository to the image
|
# Copy the local repository to the image
|
||||||
COPY . /tmp/ncc
|
COPY . /tmp/ncc
|
||||||
|
|
||||||
# Download the latest version of ncc (Nosial Code Compiler)
|
# Build ncc
|
||||||
RUN cd /tmp/ncc && make redist
|
RUN cd /tmp/ncc && make redist
|
||||||
|
|
||||||
|
|
||||||
#
|
# Main stage: Copies build files and installs all dependencies
|
||||||
# Main stage: Copies downloaded files and installs all
|
FROM php:8.2-fpm AS production
|
||||||
#
|
LABEL maintainer="netkas <netkas@nosial.net>"
|
||||||
|
LABEL description="ncc debian docker image"
|
||||||
FROM php:8.2-fpm
|
|
||||||
|
|
||||||
# Add extensions
|
|
||||||
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
||||||
|
|
||||||
# Copy downloaded files
|
# Copy downloaded files
|
||||||
COPY --from=builder /tmp/. .
|
COPY --from=builder /tmp/ncc_build/. .
|
||||||
|
|
||||||
# Install some stuff the default image doesn't come with
|
# Install some stuff the default image doesn't come with
|
||||||
RUN apt update -yqq; \
|
RUN apt-get update -yqq && \
|
||||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
apt-get install -yqq git libpq-dev libzip-dev zip make wget gnupg gcc -yqq
|
||||||
|
|
||||||
# Install extensions required to run ncc
|
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
|
||||||
RUN install-php-extensions mbstring \
|
install-php-extensions zip xsl
|
||||||
ctype \
|
|
||||||
common; \
|
|
||||||
# Add git
|
|
||||||
apt install -y git; \
|
|
||||||
# Install phive, phab and ncc; create workdir
|
|
||||||
chmod +x phive.phar; \
|
|
||||||
mv phive.phar /usr/local/bin/phive; \
|
|
||||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C; \
|
|
||||||
cd ncc; php build/src/INSTALL --auto --install-composer; cd ..; rm -rf ncc; \
|
|
||||||
mkdir /app
|
|
||||||
|
|
||||||
WORKDIR /app
|
# Install ncc
|
||||||
|
RUN php INSTALL --auto; cd ../; rm -rf ncc
|
||||||
|
|
||||||
|
# Finalize image
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
12
Makefile
12
Makefile
|
@ -8,7 +8,9 @@ INSTALLER_SRC_PATH := $(SRC_PATH)/installer
|
||||||
CONFIG_PATH := $(SRC_PATH)/config
|
CONFIG_PATH := $(SRC_PATH)/config
|
||||||
BUILD_VERSION := $(shell cat $(SRC_PATH)/ncc/VERSION)
|
BUILD_VERSION := $(shell cat $(SRC_PATH)/ncc/VERSION)
|
||||||
BUILD_PATH := build
|
BUILD_PATH := build
|
||||||
GENERIC_BUILD_PATH := $(BUILD_PATH)/ncc_$(BUILD_VERSION)
|
ifndef GENERIC_BUILD_PATH
|
||||||
|
GENERIC_BUILD_PATH := $(BUILD_PATH)/ncc_$(BUILD_VERSION)
|
||||||
|
endif
|
||||||
TAR_BUILD:= ncc_$(BUILD_VERSION).tar.gz
|
TAR_BUILD:= ncc_$(BUILD_VERSION).tar.gz
|
||||||
DEBIAN_SRC_PATH := $(SRC_PATH)/debian
|
DEBIAN_SRC_PATH := $(SRC_PATH)/debian
|
||||||
DEBIAN_BUILD_PATH := $(BUILD_PATH)/debian/ncc_$(BUILD_VERSION)_all
|
DEBIAN_BUILD_PATH := $(BUILD_PATH)/debian/ncc_$(BUILD_VERSION)_all
|
||||||
|
@ -34,8 +36,10 @@ AUTOLOAD_PATHS := $(addprefix $(SRC_PATH)/ncc/ThirdParty/, \
|
||||||
ifndef PHPCC
|
ifndef PHPCC
|
||||||
$(error "PHP binary not found. Please install PHP or check your PATH")
|
$(error "PHP binary not found. Please install PHP or check your PATH")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Check if phpab is installed
|
||||||
ifndef PHPAB
|
ifndef PHPAB
|
||||||
$(error "phpab (PHP Autoload Builder) binary not found. Please install phpab or check your PATH")
|
$(error "phpab (PHP Autoload Builder) not found. Please install phpab or check your PATH")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Build rules
|
# Build rules
|
||||||
|
@ -121,6 +125,10 @@ $(DEBIAN_PACKAGE_BUILD_PATH): debian_prepare
|
||||||
.PHONY: deb
|
.PHONY: deb
|
||||||
deb: $(DEBIAN_PACKAGE_BUILD_PATH)
|
deb: $(DEBIAN_PACKAGE_BUILD_PATH)
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: redist
|
||||||
|
$(GENERIC_BUILD_PATH)/INSTALL --auto
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_PATH)
|
rm -rf $(BUILD_PATH)
|
||||||
|
|
|
@ -65,7 +65,7 @@ RUN install-php-extensions mbstring \
|
||||||
chmod +x phive.phar; \
|
chmod +x phive.phar; \
|
||||||
mv phive.phar /usr/local/bin/phive; \
|
mv phive.phar /usr/local/bin/phive; \
|
||||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C; \
|
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C; \
|
||||||
cd ncc; php build/src/INSTALL --auto --install-composer; cd ..; rm -rf ncc; \
|
cd ncc; php build/src/INSTALL --auto; cd ..; rm -rf ncc; \
|
||||||
mkdir /app
|
mkdir /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
74
old_docker/Dockerfile.debian
Normal file
74
old_docker/Dockerfile.debian
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
# Copyright 2022-2023 Nosial - All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||||
|
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||||
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||||
|
# Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||||
|
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# ncc in Docker
|
||||||
|
#
|
||||||
|
# This image is intended to be used as a base for projects using ncc.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Builder stage: downloads necessary files and serves them on a silver platter.
|
||||||
|
#
|
||||||
|
|
||||||
|
FROM php:8.2-fpm AS builder
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
# Install some stuff the default image doesn't come with
|
||||||
|
RUN apt update -yqq; \
|
||||||
|
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||||
|
|
||||||
|
# Download phive and install phab
|
||||||
|
RUN wget -O phive.phar https://phar.io/releases/phive.phar; \
|
||||||
|
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc; \
|
||||||
|
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79; \
|
||||||
|
gpg --verify phive.phar.asc phive.phar; \
|
||||||
|
rm phive.phar.asc; chmod +x phive.phar; ./phive.phar install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||||
|
|
||||||
|
# Copy the local repository to the image
|
||||||
|
COPY . /tmp/ncc
|
||||||
|
|
||||||
|
# Download the latest version of ncc (Nosial Code Compiler)
|
||||||
|
RUN cd /tmp/ncc && make redist
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Main stage: Copies downloaded files and installs all
|
||||||
|
#
|
||||||
|
FROM php:8.2-fpm
|
||||||
|
|
||||||
|
# Add extensions
|
||||||
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
||||||
|
|
||||||
|
# Copy downloaded files
|
||||||
|
COPY --from=builder /tmp/. .
|
||||||
|
|
||||||
|
# Install some stuff the default image doesn't come with
|
||||||
|
RUN apt update -yqq; \
|
||||||
|
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||||
|
|
||||||
|
# Install extensions required to run ncc
|
||||||
|
RUN install-php-extensions mbstring \
|
||||||
|
ctype \
|
||||||
|
common; \
|
||||||
|
# Add git
|
||||||
|
apt install -y git; \
|
||||||
|
# Install phive, phab and ncc; create workdir
|
||||||
|
chmod +x phive.phar; \
|
||||||
|
mv phive.phar /usr/local/bin/phive; \
|
||||||
|
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C; \
|
||||||
|
cd ncc; php build/src/INSTALL --auto; cd ..; rm -rf ncc; \
|
||||||
|
mkdir /app
|
||||||
|
|
||||||
|
WORKDIR /app
|
2
old_docker/note.txt
Normal file
2
old_docker/note.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
These are the old dockerfiles for ncc, they are no longer used. The new dockerfiles are in the root of the repository.
|
||||||
|
These files are kept for reference and may be removed in the future.
|
Loading…
Add table
Reference in a new issue