Skip to content

Instantly share code, notes, and snippets.

@mayorova
Last active July 31, 2021 02:50
Show Gist options
  • Save mayorova/9d396e52780a637d6894018b7ec8f648 to your computer and use it in GitHub Desktop.
Save mayorova/9d396e52780a637d6894018b7ec8f648 to your computer and use it in GitHub Desktop.
Run APIcast native on Centos 7

Build the image:

docker build . -t centos-apicast

Run the container:

docker run --rm centos-apicast

If WORKDIR ${USER_HOME}/apicast-3.2.0 is enabled it works OK, but if it is commented out – apicast -h fails because the libraries can't be resolved.

FROM centos:7
# Install dependencies
RUN yum install -y yum-utils gcc git
# Enable OpenResty repo (see RHEL section at https://openresty.org/en/linux-packages.html)
RUN yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
# Enable EPEL packages (needed for LuaRocks)
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Upgrade yum
RUN yum upgrade -y
# Install OpenResty
RUN yum install -y openresty-openssl-1.0.2k \
&& export OPENRESTY_RPM_VERSION="1.13.6.1" \
&& yum install -y \
openresty-${OPENRESTY_RPM_VERSION} \
openresty-resty-${OPENRESTY_RPM_VERSION}
# Install LuaRocks
RUN yum install -y luarocks-2.3.0
# Configure Lua environment
RUN mkdir -p /usr/share/lua/5.1/luarocks/
COPY ./site_config.lua /usr/share/lua/5.1/luarocks/
# Configure user
ARG USER_NAME=user
ENV USER_HOME="/home/${USER_NAME}"
RUN adduser --home-dir ${USER_HOME} --shell /bin/bash ${USER_NAME}
RUN passwd -d ${USER_NAME} \
&& chown -R ${USER_NAME}: ${USER_HOME}
RUN yum install -y make
WORKDIR ${USER_HOME}
# Download the v3.2.0 release (Red Hat 3scale API Management v2.2) and extract it
RUN curl -L -o apicast-3.2.0.tar.gz https://github.com/3scale/apicast/archive/v3.2.0.tar.gz \
&& tar xzvf apicast-3.2.0.tar.gz \
&& cd apicast-3.2.0 \
&& make dependencies
ENV PATH="${USER_HOME}/apicast-3.2.0/bin:${PATH}"
# Enable this line to run apicast from APIcast root directory - it works
# WORKDIR ${USER_HOME}/apicast-3.2.0
CMD apicast -h
local site_config = { }
local openresty = [[/usr/local/openresty]]
local luajit = openresty .. [[/luajit]]
site_config.LUAROCKS_SYSCONFIG=openresty .. [[/config-5.1.lua]]
site_config.LUA_INTERPRETER=[[resty]]
site_config.LUA_DIR_SET=false
site_config.LUAROCKS_PREFIX= [[/usr]]
site_config.LUA_INCDIR= luajit .. [[/include/luajit-2.1]]
site_config.LUA_LIBDIR= luajit .. [[/lib/5.1]]
site_config.LUA_BINDIR= openresty .. [[/bin]]
site_config.LUAROCKS_SYSCONFDIR=[[/etc/luarocks]]
site_config.LUAROCKS_ROCKS_TREE=[[/usr/local/openresty/luajit]]
site_config.LUAROCKS_ROCKS_SUBDIR=[[/luarocks/rocks]]
site_config.LUAROCKS_UNAME_S=[[Linux]]
site_config.LUAROCKS_UNAME_M=[[x86_64]]
site_config.LUAROCKS_DOWNLOADER=[[curl]]
site_config.LUAROCKS_MD5CHECKER=[[md5sum]]
site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[lib64]] }, include="include" }
site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[lib64]] }, include="include" }
return site_config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment