Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support setting artifact name #83

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/package-apisixty-rpm-el7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: package apisix rpm with the name apisixty.rpm for el7

on:
push:
branches: [ master ]
tags:
- "v*"
pull_request:
branches: [ master ]
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ubuntu-latest
services:
etcd:
image: bitnami/etcd:3.4.0
ports:
- 2379:2379
- 2380:2380
env:
ALLOW_NONE_AUTHENTICATION: yes
ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379

steps:
- uses: actions/checkout@v2

- name: install dependencies
run: |
sudo apt-get install -y make ruby ruby-dev rubygems build-essential
sudo gem install --no-document fpm
sudo apt-get install -y rpm

- name: packaging APISIX
run: |
make package type=rpm app=apisix version=master checkout=master image_base=centos image_tag=7 artifact=apisixty

- name: run centos7 docker and mapping rpm into container
run: |
docker run -itd -v $PWD/output:/output --name centos7Instance --net="host" docker.io/centos:7 /bin/bash

- name: install dependencies in container
run: |
docker exec centos7Instance bash -c "yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo"
docker exec centos7Instance bash -c "yum -y install openresty openresty-openssl111-devel"

- name: install APISIX by rpm in container
run: |
docker exec centos7Instance bash -c "yum -y localinstall /output/apisixty-master-0.el7.x86_64.rpm"
docker exec centos7Instance bash -c "apisix start"

- name: check and ensure APISIX is installed
run: |
code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1')
if [ ! $code -eq 200 ]; then
echo "failed: failed to install Apache APISIX by rpm"
exit 1
fi
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ image_tag="7"
iteration=0
local_code_path=0
openresty="openresty"
artifact="0"
apisix_repo="https://github.com/apache/apisix"
dashboard_repo="https://github.com/apache/apisix-dashboard"

Expand Down Expand Up @@ -57,6 +58,7 @@ define package
--build-arg PACKAGE_VERSION=$(version) \
--build-arg PACKAGE_TYPE=$(2) \
--build-arg OPENRESTY=$(openresty) \
--build-arg ARTIFACT=$(artifact) \
-f ./dockerfiles/Dockerfile.package.$(1) .
docker run -d --rm --name output --net="host" apache/$(1)-packaged-$(2):$(version)
docker cp output:/output ${PWD}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
|version |True |the version of the package|version=10.10|
|local_code_path |False | the path of local code diretory of apisix or dashboard, which depends on the app parameter|local_code_path=/home/vagrant/apisix|
|openresty |False |the openresty type that apisix depends on, its value can be `openresty` or `apisix-openresty`, the default is `openresty`|openresty=apisix-openresty|
|artifact |False |the final name of the generated artifact, if not specified, this will be the same as `app`|artifact=apisixty|
|image_base|False |the environment for packaging, if type is `rpm` the default image_base is `centos`, if type is `deb` the default image_base is `ubuntu`|image_base=centos|
|image_tag|False |the environment for packaging, it's value can be `16.04\|18.04\|20.04\|6\|7\|8`, if type is `rpm` the default image_tag is `7`, if type is `deb` the default image_tag is `20.04`|image_tag=7|

Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/Dockerfile.package.apisix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ ARG ITERATION
ARG PACKAGE_VERSION
ARG PACKAGE_TYPE
ARG OPENRESTY
ARG ARTIFACT

ENV ITERATION=${ITERATION}
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
ENV PACKAGE_TYPE=${PACKAGE_TYPE}
ENV OPENRESTY=${OPENRESTY}
ENV ARTIFACT=${ARTIFACT}

COPY --from=APISIX /tmp/build/output /tmp/build/output
COPY --from=APISIX /tmp/dist /tmp/dist
Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/Dockerfile.package.apisix-dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ FROM api7/fpm
ARG ITERATION
ARG PACKAGE_VERSION
ARG PACKAGE_TYPE
ARG ARTIFACT

ENV ITERATION=${ITERATION}
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
ENV PACKAGE_TYPE=${PACKAGE_TYPE}
ENV ARTIFACT=${ARTIFACT}

COPY --from=APISIX /tmp/build/output /tmp/build/output
COPY --from=APISIX /tmp/dist /tmp/dist
Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/Dockerfile.package.apisix-openresty
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ FROM api7/fpm
ARG ITERATION
ARG PACKAGE_VERSION
ARG PACKAGE_TYPE
ARG ARTIFACT

ENV ITERATION=${ITERATION}
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
ENV PACKAGE_TYPE=${PACKAGE_TYPE}
ENV ARTIFACT=${ARTIFACT}

COPY --from=APISIX /usr/local/openresty /tmp/build/output/openresty
COPY --from=APISIX /tmp/dist /tmp/dist
Expand Down
11 changes: 10 additions & 1 deletion package-apisix-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ set -x

mkdir /output
dist=$(cat /tmp/dist)

# Determine the name of artifact
# The defaut is apisix-dashboard
artifact="apisix-dashboard"
if [ "$ARTIFACT" != "0" ]
then
artifact=${ARTIFACT}
fi

fpm -f -s dir -t rpm \
--"$PACKAGE_TYPE"-dist "$dist" \
-n apisix-dashboard \
-n "$artifact" \
-a "$(uname -i)" \
-v "$PACKAGE_VERSION" \
--iteration "$ITERATION" \
Expand Down
11 changes: 10 additions & 1 deletion package-apisix-openresty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ set -euo pipefail
set -x
mkdir /output
dist=$(cat /tmp/dist)

# Determine the name of artifact
# The defaut is apisix-openresty
artifact="apisix-openresty"
if [ "$ARTIFACT" != "0" ]
then
artifact=${ARTIFACT}
fi

fpm -f -s dir -t rpm \
--"$PACKAGE_TYPE"-dist "$dist" \
-n apisix-openresty \
-n "$artifact" \
-a "$(uname -i)" \
-v "$PACKAGE_VERSION" \
--iteration "$ITERATION" \
Expand Down
12 changes: 10 additions & 2 deletions package-apisix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ fi
# openresty >= 1.17.8.2
# apisix-openresty >= 1.19.3.2.0
or_version="1.17.8.2"
if [ "$OPENRESTY" == "apisix-openresty"]
if [ "$OPENRESTY" == "apisix-openresty" ]
then
or_version="1.19.3.2.0"
fi

# Determine the name of artifact
# The defaut is apisix
artifact="apisix"
if [ "$ARTIFACT" != "0" ]
then
artifact=${ARTIFACT}
fi

fpm -f -s dir -t "$PACKAGE_TYPE" \
--"$PACKAGE_TYPE"-dist "$dist" \
-n apisix \
-n "$artifact" \
-a "$(uname -i)" \
-v "$PACKAGE_VERSION" \
--iteration "$ITERATION" \
Expand Down