Skip to content

Commit 29a8a63

Browse files
committed
development image based on ubi8
1 parent 132a91c commit 29a8a63

7 files changed

+128
-17
lines changed

Dockerfile.devel

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM registry.access.redhat.com/ubi8:8.5
2+
3+
ARG OPENRESTY_RPM_VERSION="1.19.3"
4+
ARG LUAROCKS_VERSION="2.3.0"
5+
6+
WORKDIR /tmp
7+
8+
ENV APP_ROOT=/opt/app-root \
9+
HOME=/opt/app-root/src \
10+
PATH=/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
11+
PLATFORM="el8"
12+
13+
RUN sed -i s/enabled=./enabled=0/g /etc/yum/pluginconf.d/subscription-manager.conf
14+
15+
RUN yum upgrade -y
16+
17+
RUN dnf install -y 'dnf-command(config-manager)'
18+
19+
RUN yum install -y \
20+
gcc make git which curl expat-devel kernel-headers openssl-devel m4 \
21+
libyaml libyaml-devel perl-local-lib perl-App-cpanminus
22+
23+
# perl-Test-Nginx
24+
RUN cpanm https://cpan.metacpan.org/authors/id/A/AG/AGENT/Test-Nginx-0.29.tar.gz
25+
26+
RUN yum config-manager --add-repo http://packages.dev.3sca.net/dev_packages_3sca_net.repo
27+
28+
RUN yum install -y \
29+
openresty-${OPENRESTY_RPM_VERSION} \
30+
openresty-resty-${OPENRESTY_RPM_VERSION} \
31+
openresty-opentracing-${OPENRESTY_RPM_VERSION} \
32+
jaegertracing-cpp-client
33+
34+
RUN ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \
35+
&& ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log \
36+
&& mkdir -p /usr/local/openresty/nginx/client_body_temp/ \
37+
&& chmod 777 /usr/local/openresty/nginx/client_body_temp/
38+
39+
COPY site_config.lua /usr/share/lua/5.1/luarocks/site_config.lua
40+
COPY config-*.lua /usr/local/openresty/config-5.1.lua
41+
42+
ENV PATH="./lua_modules/bin:/usr/local/openresty/luajit/bin/:${PATH}" \
43+
LUA_PATH="./lua_modules/share/lua/5.1/?.lua;./lua_modules/share/lua/5.1/?/init.lua;/usr/lib64/lua/5.1/?.lua;/usr/share/lua/5.1/?.lua" \
44+
LUA_CPATH="./lua_modules/lib/lua/5.1/?.so;;" \
45+
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/app-root/lib"
46+
47+
RUN yum install -y luarocks && \
48+
luarocks install --server=http://luarocks.org/dev lua-rover && \
49+
rover -v && \
50+
yum -y remove luarocks && \
51+
ln -s /usr/bin/rover /usr/local/openresty/luajit/bin/ && \
52+
chmod g+w "${HOME}/.cache" && \
53+
rm -rf /var/cache/yum && yum clean all -y && \
54+
rm -rf "${HOME}/.cache/luarocks" ./*
55+
56+
# Directory with the sources is set as the working directory so all STI scripts
57+
# can execute relative to this path.
58+
WORKDIR ${HOME}
59+
60+
# Reset permissions of modified directories and add default user
61+
RUN useradd -u 1001 -r -g 0 -d ${HOME} -s /sbin/nologin \
62+
-c "Default Application User" default && \
63+
chown -R 1001:0 ${APP_ROOT}
64+
65+
USER 1001
66+
WORKDIR ${HOME}
67+
EXPOSE 8080
68+
CMD ["/bin/bash"]

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
2+
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
13
.DEFAULT_GOAL := help
2-
34
DOCKER_COMPOSE = docker-compose
5+
DOCKER ?= $(shell which podman 2> /dev/null || which docker 2> /dev/null || echo "docker")
46
S2I = script/s2i
57
REGISTRY ?= quay.io/3scale
68
export TEST_NGINX_BINARY ?= openresty
@@ -16,8 +18,8 @@ OPENRESTY_VERSION ?= master
1618
BUILDER_IMAGE ?= quay.io/3scale/s2i-openresty-centos7:$(OPENRESTY_VERSION)
1719
RUNTIME_IMAGE ?= $(BUILDER_IMAGE)-runtime
1820

19-
DEVEL_IMAGE ?= apicast-development
20-
DEVEL_DOCKERFILE ?= Dockerfile-development
21+
DEVEL_IMAGE ?= apicast-development:latest
22+
DEVEL_DOCKERFILE ?= Dockerfile.devel
2123

2224
DEVEL_DOCKER_COMPOSE_FILE ?= docker-compose-devel.yml
2325
DEVEL_DOCKER_COMPOSE_VOLMOUNT_MAC_FILE ?= docker-compose-devel-volmount-mac.yml
@@ -64,6 +66,15 @@ export COMPOSE_PROJECT_NAME
6466

6567
.PHONY: benchmark lua_modules
6668

69+
.PHONY: dev-build
70+
dev-build: export OPENRESTY_RPM_VERSION?=1.19.3
71+
dev-build: export LUAROCKS_VERSION?=2.3.0
72+
dev-build:
73+
$(DOCKER) build -t $(DEVEL_IMAGE) \
74+
--build-arg OPENRESTY_RPM_VERSION=$(OPENRESTY_RPM_VERSION) \
75+
--build-arg LUAROCKS_VERSION=$(LUAROCKS_VERSION) \
76+
$(PROJECT_PATH) -f $(DEVEL_DOCKERFILE)
77+
6778
test: ## Run all tests
6879
$(MAKE) --keep-going busted prove builder-image test-builder-image prove-docker runtime-image test-runtime-image
6980

@@ -208,6 +219,7 @@ endif
208219
development: .docker/lua_modules .docker/local .docker/cpanm .docker/vendor/cache
209220
development: ## Run bash inside the development image
210221
@echo "Running on $(os)"
222+
@$(DOCKER) history -q $(DEVEL_IMAGE) 2> /dev/null >&2 || $(MAKE) -C $(PROJECT_PATH) -f $(MKFILE_PATH) dev-build
211223
- $(DOCKER_COMPOSE) -f $(DEVEL_DOCKER_COMPOSE_FILE) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE) up -d
212224
@ # https://github.com/moby/moby/issues/33794#issuecomment-312873988 for fixing the terminal width
213225
$(DOCKER_COMPOSE) -f $(DEVEL_DOCKER_COMPOSE_FILE) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE) exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" --user $(USER) development bash

config-5.1.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lua_interpreter = [[resty]]
2+
lib_modules_path = [[/lib/lua/]]..lua_version
3+
4+
variables = {
5+
LUAROCKS_PREFIX = [[/usr]]
6+
}

docker-compose-devel-volmount-default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
privileged: true
55
pid: "host"
66
volumes:
7-
- .:/home/centos/
8-
- .docker/cpanm:/home/centos/.cpanm
7+
- .:/opt/app-root/src/
8+
- .docker/cpanm:/opt/app-root/src/.cpanm
99
- /sys/kernel/debug:/sys/kernel/debug
1010
- /lib/modules:/lib/module

docker-compose-devel-volmount-mac.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ version: '2.2'
22
services:
33
development:
44
volumes:
5-
- .:/home/centos/:cached
6-
- .docker/cpanm:/home/centos/.cpanm:delegated
5+
- .:/opt/app-root/src/:cached
6+
- .docker/cpanm:/opt/app-root/src/.cpanm:delegated

docker-compose-devel.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1+
---
12
version: '2.2'
23
services:
34
development:
4-
image: ${IMAGE:-quay.io/3scale/s2i-openresty-centos7:1.19.3.6-20-centos8}
5+
image: ${IMAGE:-apicast-development:latest}
56
depends_on:
67
- redis
7-
working_dir: /home/centos/
8+
working_dir: /opt/app-root/src/
89
volumes:
9-
- .docker/lua_modules:/home/centos/lua_modules
10-
- .docker/local:/home/centos/local
11-
- .docker/vendor/cache:/home/centos/vendor/cache
10+
- .docker/lua_modules:/opt/app-root/src/lua_modules
11+
- .docker/local:/opt/app-root/src/local
12+
- .docker/vendor/cache:/opt/app-root/src/vendor/cache
1213
# no need to access those from docker
13-
- /home/centos/.docker
14-
- /home/centos/.git
14+
- /opt/app-root/src/.docker
15+
- /opt/app-root/src/.git
1516
command: cat
1617
tty: true
1718
init: true
1819
environment:
1920
EDITOR: vi
2021
TEST_NGINX_REDIS_HOST: redis
2122
TEST_NGINX_BINARY: openresty
22-
PROJECT_PATH: /home/centos
23-
TEST_NGINX_APICAST_PATH: /home/centos/gateway
23+
PROJECT_PATH: /opt/app-root/src
24+
TEST_NGINX_APICAST_PATH: /opt/app-root/src/gateway
2425
ROVER: /usr/local/openresty/luajit/bin/rover
25-
HOME: /home/centos/
26+
HOME: /opt/app-root/src/
2627
# https://github.com/jenkinsci/docker/issues/519#issuecomment-313052325
2728
GIT_COMMITTER_NAME: ${GIT_COMMITTER_NAME:-${USER}}
2829
GIT_COMMITTER_EMAIL: ${GIT_COMMITTER_EMAIL:-""}

site_config.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
local site_config = { }
2+
3+
local openresty = [[/usr/local/openresty]]
4+
local luajit = openresty .. [[/luajit]]
5+
6+
site_config.LUAROCKS_SYSCONFIG=openresty .. [[/config-5.1.lua]]
7+
site_config.LUA_INTERPRETER=[[resty]]
8+
site_config.LUA_DIR_SET=false
9+
site_config.LUAROCKS_PREFIX= [[/usr]]
10+
site_config.LUA_INCDIR= luajit .. [[/include/luajit-2.1]]
11+
site_config.LUA_LIBDIR= luajit .. [[/lib/5.1]]
12+
site_config.LUA_BINDIR= openresty .. [[/bin]]
13+
site_config.LUAROCKS_SYSCONFDIR=[[/etc/luarocks]]
14+
site_config.LUAROCKS_ROCKS_TREE=[[/usr/local/openresty/luajit]]
15+
site_config.LUAROCKS_ROCKS_SUBDIR=[[/luarocks/rocks]]
16+
site_config.LUAROCKS_UNAME_S=[[Linux]]
17+
site_config.LUAROCKS_UNAME_M=[[x86_64]]
18+
site_config.LUAROCKS_DOWNLOADER=[[curl]]
19+
site_config.LUAROCKS_MD5CHECKER=[[md5sum]]
20+
21+
site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[lib64]] }, include="include" }
22+
site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[lib64]] }, include="include" }
23+
24+
return site_config

0 commit comments

Comments
 (0)