Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3eb6ae

Browse files
Refactoring of dockerfiles (#215)
* Refactoring of dockerfilesLet's to try using a pure dockerfile' logic.It is the fist step.- We use docker instead docker-composer- We upgrade and use only "std" plaform. Other plaforms will be upgraded later* It is better to run a docker with "-t" options.This allows the colors in output data.* A problem with PYTHON_VERSION is fixed* Dockerfile--std.all.tmpl is updated* Dockerfile--ubuntu-24_04.tmpl* Dockerfile--std.tmpl is updated (formatting)* docker-compose.yml and mk_dockerfile.sh are deleted* [CI] Platform "std.all" was renamed with "std_all"Let's avoid using a "point" symbol in name of file. This symbol may create a problem in the future if we decide to use configuration docker files without extensions.* [CI] Platform name has the one format Dockerfiles--<platform>[-<info>].tmpl- "std_all" -> "std-all"- "ubuntu-24_04" -> "ubuntu_24_04"* Dockerfile--ubuntu_24_04.tmpl is updated (minimization)
1 parentf2c000c commite3eb6ae

6 files changed

+69
-48
lines changed

‎.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ services:
88
-docker
99

1010
install:
11-
-./mk_dockerfile.sh
12-
-docker-compose build
11+
-docker build --build-arg PG_VERSION="${PG_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" -t tests -f Dockerfile--${TEST_PLATFORM}.tmpl .
1312

1413
script:
15-
-docker-compose run $(bash <(curl -s https://codecov.io/env)) tests
14+
-docker run $(bash <(curl -s https://codecov.io/env)) -t tests
1615

1716
notifications:
1817
email:
@@ -27,5 +26,5 @@ env:
2726
-TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=12
2827
-TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=11
2928
-TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=10
30-
-TEST_PLATFORM=std.all PYTHON_VERSION=3 PG_VERSION=17
31-
-TEST_PLATFORM=ubuntu-24_04 PYTHON_VERSION=3 PG_VERSION=17
29+
-TEST_PLATFORM=std-all PYTHON_VERSION=3 PG_VERSION=17
30+
-TEST_PLATFORM=ubuntu_24_04 PYTHON_VERSION=3 PG_VERSION=17

‎Dockerfile--std.all.tmplrenamed to‎Dockerfile--std-all.tmpl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
FROM postgres:${PG_VERSION}-alpine
2-
3-
ENV PYTHON=python${PYTHON_VERSION}
4-
RUN if [ "${PYTHON_VERSION}" = "2" ] ; then \
5-
apk add --no-cache curl python2 python2-dev build-base musl-dev \
6-
linux-headers py-virtualenv py-pip; \
7-
fi
8-
RUN if [ "${PYTHON_VERSION}" = "3" ] ; then \
9-
apk add --no-cache curl python3 python3-dev build-base musl-dev \
10-
linux-headers py-virtualenv; \
11-
fi
1+
ARG PG_VERSION
2+
ARG PYTHON_VERSION
3+
4+
# --------------------------------------------- base1
5+
FROM postgres:${PG_VERSION}-alpine as base1
6+
7+
# --------------------------------------------- base2_with_python-2
8+
FROM base1 as base2_with_python-2
9+
RUN apk add --no-cache curl python2 python2-dev build-base musl-dev linux-headers py-virtualenv py-pip
10+
ENV PYTHON_VERSION=2
11+
12+
# --------------------------------------------- base2_with_python-3
13+
FROM base1 as base2_with_python-3
14+
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers py-virtualenv
15+
ENV PYTHON_VERSION=3
16+
17+
# --------------------------------------------- final
18+
FROM base2_with_python-${PYTHON_VERSION} as final
1219

1320
#RUN apk add --no-cache mc
1421

@@ -57,4 +64,4 @@ ls -la ~/.ssh/; \
5764
sudo /usr/sbin/sshd; \
5865
ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \
5966
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \
60-
TEST_FILTER=\"\"PYTHON_VERSION=${PYTHON_VERSION}bash run_tests.sh;"
67+
TEST_FILTER=\"\" bash run_tests.sh;"

‎Dockerfile--std.tmpl

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
FROM postgres:${PG_VERSION}-alpine
1+
ARG PG_VERSION
2+
ARG PYTHON_VERSION
3+
4+
# --------------------------------------------- base1
5+
FROM postgres:${PG_VERSION}-alpine as base1
6+
7+
# --------------------------------------------- base2_with_python-2
8+
FROM base1 as base2_with_python-2
9+
RUN apk add --no-cache curl python2 python2-dev build-base musl-dev linux-headers py-virtualenv py-pip
10+
ENV PYTHON_VERSION=2
11+
12+
# --------------------------------------------- base2_with_python-3
13+
FROM base1 as base2_with_python-3
14+
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers py-virtualenv
15+
ENV PYTHON_VERSION=3
16+
17+
# --------------------------------------------- final
18+
FROM base2_with_python-${PYTHON_VERSION} as final
219

3-
ENV PYTHON=python${PYTHON_VERSION}
4-
RUN if [ "${PYTHON_VERSION}" = "2" ] ; then \
5-
apk add --no-cache curl python2 python2-dev build-base musl-dev \
6-
linux-headers py-virtualenv py-pip; \
7-
fi
8-
RUN if [ "${PYTHON_VERSION}" = "3" ] ; then \
9-
apk add --no-cache curl python3 python3-dev build-base musl-dev \
10-
linux-headers py-virtualenv; \
11-
fi
1220
ENV LANG=C.UTF-8
1321

1422
ADD . /pg/testgres
1523
WORKDIR /pg/testgres
1624
RUN chown -R postgres:postgres /pg
1725

1826
USER postgres
19-
ENTRYPOINTPYTHON_VERSION=${PYTHON_VERSION}bash run_tests.sh
27+
ENTRYPOINT bash run_tests.sh
Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
FROM ubuntu:24.04
1+
ARG PG_VERSION
2+
ARG PYTHON_VERSION
3+
4+
# --------------------------------------------- base1
5+
FROM ubuntu:24.04 as base1
6+
ARG PG_VERSION
7+
8+
RUN apt update
9+
RUN apt install -y sudo curl ca-certificates
10+
RUN apt update
11+
RUN apt install -y openssh-server
212

313
RUN apt update
4-
RUN apt install -ysudo curl ca-certificatespostgresql-common
14+
RUN apt install -y postgresql-common
515

616
RUN bash /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
717

@@ -14,35 +24,38 @@ RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail http
1424
RUN apt update
1525
RUN apt install -y postgresql-${PG_VERSION}
1626

17-
RUN apt install -y python3 python3-dev python3-virtualenv
1827
# RUN apt install -y mc
1928

20-
# It is required for psycopg2
21-
RUN apt install -y libpq-dev
22-
RUN apt install -y openssh-server
23-
2429
# [2025-02-26] It adds the user 'postgres' in the group 'sudo'
2530
# [2025-02-27] It is not required.
2631
# RUN adduser postgres sudo
2732

28-
ADD . /pg/testgres
29-
WORKDIR /pg/testgres
30-
RUN chown -R postgres /pg
31-
3233
EXPOSE 22
3334

3435
RUN ssh-keygen -A
3536

3637
# It enables execution of "sudo service ssh start" without password
3738
RUN sh -c "echo postgres ALL=NOPASSWD:/usr/sbin/service ssh start" >> /etc/sudoers
3839

39-
USER postgres
40+
# --------------------------------------------- base2_with_python-3
41+
FROM base1 as base2_with_python-3
42+
RUN apt install -y python3 python3-dev python3-virtualenv libpq-dev
43+
ENV PYTHON_VERSION=3
44+
45+
# --------------------------------------------- final
46+
FROM base2_with_python-${PYTHON_VERSION} as final
47+
48+
ADD . /pg/testgres
49+
WORKDIR /pg/testgres
50+
RUN chown -R postgres /pg
51+
4052
ENV LANG=C.UTF-8
4153

54+
USER postgres
55+
4256
RUN chmod 700 ~/
4357
RUN mkdir -p ~/.ssh
4458

45-
#ENTRYPOINT PYTHON_VERSION=3.12 /run.sh
4659
ENTRYPOINT sh -c " \
4760
#set -eux; \
4861
echo HELLO FROM ENTRYPOINT; \
@@ -55,4 +68,4 @@ ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \
5568
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \
5669
chmod 600 ~/.ssh/authorized_keys; \
5770
ls -la ~/.ssh/; \
58-
TEST_FILTER=\"\"PYTHON_VERSION=${PYTHON_VERSION}bash run_tests.sh;"
71+
TEST_FILTER=\"\" bash./run_tests.sh;"

‎docker-compose.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎mk_dockerfile.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp