我是新的Codenvy用户。我试图在Codenvy建立一个“堆栈”,它将运行postgres。
我正在使用以下配方创建我的堆栈。 (使用https://github.com/eclipse/che-dockerfiles/blob/master/recipes/ubuntu_jdk8/Dockerfile作为起点)
此配方创建一个包含Eclipse Che,Maven和Tomcat的Codenvy服务器。
我需要将Ant和Postgres添加到此配置中。我能够添加Ant。我目前面临的挑战是将Postgres添加到此配置中。
这是我目前的食谱。
FROM eclipse/stack-base:ubuntu
EXPOSE 4403 8000 8080 9876 22
LABEL che:server:8080:ref=tomcat8 che:server:8080:protocol=http
che:server:8000:ref=tomcat8-debug che:server:8000:protocol=http
che:server:9876:ref=codeserver che:server:9876:protocol=http
ENV MAVEN_VERSION=3.3.9 \
ANT_VERSION=1.10.1 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
TOMCAT_HOME=/home/user/tomcat8 \
TERM=xterm
ENV M2_HOME=/home/user/apache-maven-$MAVEN_VERSION
ENV ANT_HOME=/home/user/ant-$ANT_VERSION
ENV PATH=$JAVA_HOME/bin:$M2_HOME/bin:$ANT_HOME/bin:$PATH
RUN mkdir /home/user/tomcat8 /home/user/apache-maven-$MAVEN_VERSION
$ANT_HOME && \
wget -qO- "https://www.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME && \
wget -qO- "http://apache.ip-connect.vn.ua/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C /home/user/apache-maven-$MAVEN_VERSION/ && \
wget -qO- "http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz" | tar -zx --strip-components=1 -C /home/user/tomcat8 && \
rm -rf /home/user/tomcat8/webapps/* && \
echo "export MAVEN_OPTS=\$JAVA_OPTS" >> /home/user/.bashrc
我找到了一个使用以下命令安装postgres的示例dockerfile
RUN apt-get update && apt-get install -y ant git postgresql-client postgresql-contrib
当我将此添加到我的Codenvy Stack配方中时,我在尝试启动工作区时看到失败。
[DOCKER] Step 13/13 : RUN apt-get update && apt-get install -y ant git postgresql-client postgresql-contrib
[DOCKER] ---> Running in 672fc2aac027
[DOCKER] Reading package lists...
[DOCKER]
[DOCKER] [91mE: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
[0m
[DOCKER] Removing intermediate container 672fc2aac027
[DOCKER]
[DOCKER] [ERROR] Failed to build image: The command '/bin/sh -c apt-get update && apt-get install -y ant git postgresql-client postgresql-contrib' returned a non-zero code: 100
在此环境中安装postgres的正确方法是什么?安装完成后,如何确保postgres服务已启动?
答案 0 :(得分:0)
Docker的主要好处之一不是重新发明轮子。您应该使用官方PostgreSQL image。
如果基础PostgreSQL图像不足以满足您的需求,请继承它并在顶部添加您需要的任何内容。
作为一般规则,如果您要在#!/bin/sh
MONITORDIR="/path/to/directory"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read
NEWFILE
do
[ -z "${NEWFILE}" ] && : || MOVIE=$(find "$NEWFILE" -type f -not -name ".*"
\( -iname "*.mkv" -o -iname "*.mp4" -o -iname "*.avi" \) -exec basename {}
\; | sed 's/\.[^.]*$//')
[ -z "${MOVIE}" ] && : || echo "Please don't reply to this
automatically generated email message." | mail -s "$MOVIE is now on Plex!"
"email1@gmail.com,email2@gmail.com"
done
之外构建图像,请三思而后行,因为您可能使用了错误的工具来完成工作。
答案 1 :(得分:0)
我在GitHub的codenvy repo的帮助下解决了这个问题。
请参阅https://github.com/codenvy/codenvy/issues/2413
FROM eclipse/stack-base:ubuntu
EXPOSE 4403 8000 8080 9876 22
LABEL che:server:8080:ref=tomcat8 che:server:8080:protocol=http che:server:8000:ref=tomcat8-debug che:server:8000:protocol=http che:server:9876:ref=codeserver che:server:9876:protocol=http
ENV MAVEN_VERSION=3.3.9 \
ANT_VERSION=1.10.1 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
TOMCAT_HOME=/home/user/tomcat8 \
TERM=xterm
ENV M2_HOME=/home/user/apache-maven-$MAVEN_VERSION
ENV ANT_HOME=/home/user/ant-$ANT_VERSION
ENV PATH=$JAVA_HOME/bin:$M2_HOME/bin:$ANT_HOME/bin:$PATH
RUN mkdir /home/user/tomcat8 /home/user/apache-maven-$MAVEN_VERSION $ANT_HOME && \
wget -qO- "https://www.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME && \
wget -qO- "http://apache.ip-connect.vn.ua/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C /home/user/apache-maven-$MAVEN_VERSION/ && \
wget -qO- "http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz" | tar -zx --strip-components=1 -C /home/user/tomcat8 && \
rm -rf /home/user/tomcat8/webapps/* && \
echo "export MAVEN_OPTS=\$JAVA_OPTS" >> /home/user/.bashrc
USER root
RUN set -ex; \
key='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8'; \
export GNUPGHOME="$(mktemp -d)"; \
sudo gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
sudo gpg --export "$key" > /etc/apt/trusted.gpg.d/postgres.gpg; \
rm -r "$GNUPGHOME"; \
sudo apt-key list
ENV PG_MAJOR 9.5
ENV PG_VERSION 9.5.2-1
RUN sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
USER user
RUN sudo apt-get update \
&& sudo apt-get install -y postgresql-common \
&& sudo sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
&& sudo apt-get install -y \
postgresql-$PG_MAJOR=$PG_VERSION \
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
&& sudo rm -rf /var/lib/apt/lists/*
RUN sudo mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/postgresql/ \
&& sudo ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
&& sudo sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
RUN sudo mkdir -p /var/run/postgresql && sudo chown -R postgres:postgres /var/run/postgresql && sudo chmod g+s /var/run/postgresql
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
ENV PGDATA /var/lib/postgresql/data
RUN sudo mkdir -p "$PGDATA" && sudo chown -R postgres:postgres "$PGDATA" && sudo chmod 777 "$PGDATA"
VOLUME /var/lib/postgresql/data
CMD sudo pg_createcluster $PG_MAJOR main --start && sudo service postgresql start & tail -f /dev/null