I am trying to setup CI in GitLab.
Building OS: Alpine Linux Container, actually it is Docker-In-Docker
image. (see Dockerfile below)
Targeting OS: x86_64-unknown-linux-gnu
Building Tool: cross https://github.com/rust-embedded/cross
Error: undefined reference to `__res_init'
Full log : https://github.com/rust-embedded/cross/files/4894721/build.log
Here is Dockerfile of Alpine running cross
FROM docker:stable-dind
RUN apk add --no-cache ca-certificates gcc mingw-w64-gcc libc-dev musl-dev
# Copied from https://github.com/rust-lang/docker-rust/blob/6314c6bc3d54d5b9284458c6a9061ef5766c9607/1.44.1/alpine3.12/Dockerfile
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.44.1
RUN set -eux; \
url="https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-musl/rustup-init"; \
wget "$url"; \
echo "0c86d467982bdf5c4b8d844bf8c3f7fc602cc4ac30b29262b8941d6d8b363d7e *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version;
RUN cargo install cross
RUN rustup target add x86_64-pc-windows-gnu
RUN rustup target add x86_64-unknown-linux-gnu
ENV CROSS_DOCKER_IN_DOCKER=true
RUN mkdir ~/.cargo/ && \
printf "\n[target.x86_64-pc-windows-gnu]" >> ~/.cargo/config && \
printf "\nlinker = \"/usr/bin/x86_64-w64-mingw32-gcc\"" >> ~/.cargo/config
Related
With this zip file, this Node script successfully outputs the files:
const child_process = require('child_process')
const util = require('util')
const exec = util.promisify(child_process.exec)
exec(`unzip -Z1 metamorpR.zip`).then(zip_contents => {
if (zip_contents.stderr) {
throw new Error(`unzip error: ${zip_contents.stderr}`)
}
console.log(zip_contents.stdout)
})
metamorpR.z5
Варианты Прохождения.txt
Интерактивная Литература.pdf
But when I run the script from within Docker, it doesn't.
Using this Dockerfile:
FROM node:16-alpine
RUN apk add --no-cache unzip
COPY . .
ENTRYPOINT ["node", "unzip.js"]
Build and run (substitute in your container image name):
docker build .
docker run --rm 1dc072
Output:
metamorpR.z5
??????? ????????.txt
???????????? ??????????.pdf
I think this means the locales aren't set correctly within the Docker image? Any ideas how to fix this?
TL;DR
unzip on alpine doesn't appear to support locales. unzip on debian doesn't appear to support locales either. unzip on ubuntu supports using locales (however there exists no official node ubuntu image).
On ubuntu:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
locales \
unzip && \
apt-get clean
RUN sed -i -e 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen && \
update-locale LANG=ru_RU.UTF-8 LC_ALL=ru_RU.UTF-8 && \
ldconfig
ENV LANG=ru_RU.UTF-8
COPY metamorpR.zip /metamorpR.zip
CMD ["unzip", "-l", "metamorpR.zip"]
... there are no issues in the unzip file name output:
... however the same build FROM node:16-bullseye won't produce the same results:
You could apply this patch during the build, then generate the locales, however unzip doesn't appear to use the locales:
FROM node:16-alpine
RUN apk add --no-cache unzip wget
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-bin-2.34-r0.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-i18n-2.34-r0.apk && \
apk add glibc-2.34-r0.apk glibc-bin-2.34-r0.apk glibc-i18n-2.34-r0.apk && \
rm /glibc-2.34-r0.apk /glibc-bin-2.34-r0.apk /glibc-i18n-2.34-r0.apk && \
/usr/glibc-compat/bin/localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
ENV LANG=ru_RU.UTF-8
COPY metamorpR.zip /metamorpR.zip
CMD ["unzip", "-l", "metamorpR.zip"]
Thanks to #masseyb's answer, I was able to get it working with this Dockerfile, which basically just installs Node manually into an Ubuntu image. The main downside is the image is twice the size, but it's comparatively simple so that's an acceptable downside to me.
FROM ubuntu:20.04
RUN apt-get update && \
apt install -y curl locales unzip && \
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
apt install -y nodejs && \
rm -rf /var/lib/apt/lists/* && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.UTF-8
COPY . .
ENTRYPOINT ["node", "unzip.js"]
Apparently some versions of unzip that is available from Ubuntu repositories can handle automatic decoding of filenames if you specify the -a switch.
I'm trying to statically build my rust application, using MUSL.
My application uses sqlcipher. This means a statically built executable must include the openssl and sqlcipher C libraries.
I'm using https://github.com/emk/rust-musl-builder, so I wrote a Dockerfile which starts with their dockerfile, which already provides a MUSL environment including a statically built musl-enabled openssl.
So "all I need" is to build sqlcipher and then my rust application. Unfortunately this has a proven very complicated for me.
Here is my current docker file:
FROM ekidd/rust-musl-builder
# sqlcipher requirements
ENV TZ=Europe/Ljubljana
RUN sudo sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone"
RUN sudo apt update
RUN sudo apt install tcl -y
# sqlcipher
RUN VERS=4.4.1 && \
cd /home/rust/libs && \
curl -LO https://github.com/sqlcipher/sqlcipher/archive/v$VERS.tar.gz && \
tar xzf v$VERS.tar.gz && cd sqlcipher-$VERS && \
CC=musl-gcc ./configure --host=x86_64-pc-linux-gnu --target=x86_64-linux-musl --prefix=/usr/local/musl --disable-tcl --disable-shared --with-crypto-lib=none --enable-static=yes --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -I/usr/include/x86_64-linux-musl -I/usr/local/musl/include -I/usr/local/musl/include/openssl" LDFLAGS=" /usr/local/musl/lib/libcrypto.a" && \
make && sudo make install && \
cd .. && rm -rf v$VERS.tar.gz sqlcipher-$VERS
# bring in my rust source
ADD --chown=rust:rust ./ .
# build my rust code
ENV RUSTFLAGS='-L/usr/local/musl/lib -L/usr/lib/x86_64-linux-musl -L/lib/x86_64-linux-musl -C linker=musl-gcc -Clink-arg=/usr/local/musl/lib/libcrypto.a -Clink-arg=/usr/local/musl/lib/libsqlcipher.a -C link-arg=/lib/ld-musl-x86_64.so.1 -Clink-arg=/usr/lib/x86_64-linux-musl/libc.a -Ctarget-feature=-crt-static -Clink-arg=-no-pie -C target-feature=+crt-static'
ENV PKG_CONFIG_ALLOW_CROSS=1
ENV PKG_CONFIG_ALL_STATIC=true
ENV OPENSSL_STATIC=true
ENV LIBZ_SYS_STATIC=1
CMD cargo build --target x86_64-unknown-linux-musl --release --bin projectpad-cli && cp /home/rust/src/target/x86_64-unknown-linux-musl/release/projectpad-cli /host
(my rust source is at https://github.com/emmanueltouzery/projectpad2)
This succeeds entirely and generates a binary, but it's not statically linked:
ldd projectpad-cli
/lib/ld-musl-x86_64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007f56d6749000)
linux-vdso.so.1 (0x00007fff301f7000)
file projectpad-cli
projectpad-cli: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, with debug_info, not stripped
Attempting to run this binary crashes in malloc_usable_size () from /lib/ld-musl-x86_64.so.1.
I believe it's because my system doesn't have the MUSL linker and so it uses the glibc/gcc one, and this causes issues.
I'm thinking that if I could manage to produce a really static binary, that wouldn't have references to the linker, this would possibly work.
Any idea what I'm doing wrong? I experimented with some builder.rs printlns, but I currently don't have any.
OK, I found it...
I'm pretty sure the problem was the -C link-arg=/lib/ld-musl-x86_64.so.1 flag. This more or less forced a dynamic executable I think. Removing it fixed the issue :-)
# -*- mode: dockerfile -*-
#
# An example Dockerfile showing how to add new static C libraries using
# musl-gcc.
FROM ekidd/rust-musl-builder
# https://rtfm.co.ua/en/docker-configure-tzdata-and-timezone-during-build/
ENV TZ=Europe/Ljubljana
RUN sudo sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone"
RUN sudo apt update
RUN sudo apt install tcl -y
# Build a static copy of sqlcipher.
# https://github.com/sqlcipher/sqlcipher/issues/132#issuecomment-122908672
# also related https://discuss.zetetic.net/t/cross-compile-sqlicipher-for-arm/2104/4
# https://github.com/sqlcipher/sqlcipher/issues/276
# https://github.com/rust-lang/rust/issues/40049
RUN VERS=4.4.1 && \
cd /home/rust/libs && \
curl -LO https://github.com/sqlcipher/sqlcipher/archive/v$VERS.tar.gz && \
tar xzf v$VERS.tar.gz && cd sqlcipher-$VERS && \
CC=musl-gcc ./configure --host=x86_64-pc-linux-gnu --target=x86_64-linux-musl --prefix=/usr/local/musl --disable-tcl --disable-shared --with-crypto-lib=none --enable-static=yes --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -I/usr/include/x86_64-linux-musl -I/usr/local/musl/include -I/usr/local/musl/include/openssl" LDFLAGS=" /usr/local/musl/lib/libcrypto.a" && \
make && sudo make install && \
cd .. && rm -rf v$VERS.tar.gz sqlcipher-$VERS
ADD --chown=rust:rust ./ .
# https://stackoverflow.com/questions/40695010/how-to-compile-a-static-musl-binary-of-a-rust-project-with-native-dependencies
# https://github.com/rust-lang/rust/issues/54243
ENV RUSTFLAGS='-L/usr/local/musl/lib -L/usr/lib/x86_64-linux-musl -L/lib/x86_64-linux-musl -C linker=musl-gcc -Clink-arg=/usr/local/musl/lib/libcrypto.a -Clink-arg=/usr/local/musl/lib/libsqlcipher.a -Clink-arg=/usr/lib/x86_64-linux-musl/libc.a'
ENV PKG_CONFIG_ALLOW_CROSS=1
ENV PKG_CONFIG_ALL_STATIC=true
ENV OPENSSL_STATIC=true
ENV LIBZ_SYS_STATIC=1
CMD cargo build --target x86_64-unknown-linux-musl --release --bin projectpad-cli && cp /home/rust/src/target/x86_64-unknown-linux-musl/release/projectpad-cli /host
In my Dockerized Symfony 4.4 project I can switch between dev and prod environments with two commands : make up-dev and make up-prod (using Makefile)
In dev mode, inside the container, I can install LiipImagineBundle with no problem, then when I switch to prod environment the make up-prod exits with this error message :
Generated optimized autoload files containing 7171 classes
+ APP_ENV=prod composer run-script --no-dev post-install-cmd
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! // Clearing the cache for the prod environment with debug
!! // false
!!
!!
!! In EnvVarProcessor.php line 171:
!!
!! Environment variable not found: "APP_SECRET".
!!
!!
!! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!
!!
Script #auto-scripts was called via post-install-cmd
ERROR: Service 'app' failed to build: The command '/bin/sh -c set -eux; mkdir -p var/cache var/log; chmod +x bin/console; composer dump-autoload --no-dev --no-scripts --optimize; APP_ENV=prod composer run-script --no-dev post-install-cmd' returned a non-zero code: 1
make: *** [Makefile:26: up] Error 1
This is my Dockerfile :
##
# Base
##
FROM debian:9-slim as base
ENV TERM="xterm" \
DEBIAN_FRONTEND="noninteractive" \
TIMEZONE="Europe/Paris" \
COMPOSER_ALLOW_SUPERUSER=1 \
NODE_VERSION=8.12.0 \
PHP_VERSION=7.2
# System depdendencies
RUN apt-get update --quiet && \
apt-get install --quiet --no-install-recommends --yes \
apt-transport-https \
ca-certificates \
lsb-release \
wget && \
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" >> /etc/apt/sources.list.d/php.list && \
apt-get update --quiet && \
apt-get install --quiet --no-install-recommends --yes \
curl \
git \
nginx \
php${PHP_VERSION} \
php${PHP_VERSION}-apcu \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-dom \
php${PHP_VERSION}-fpm \
php${PHP_VERSION}-gd \
php${PHP_VERSION}-iconv \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-opcache \
php${PHP_VERSION}-pdo \
php${PHP_VERSION}-uuid \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-simplexml \
php${PHP_VERSION}-zip \
supervisor \
p7zip-full \
tzdata \
unzip \
libxml2-dev \
php${PHP_VERSION}-soap \
vim && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
mkdir /run/php && \
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \
echo "${TIMEZONE}" > /etc/timezone
# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative && \
composer clear-cache
# Yarn
RUN curl -L -o /tmp/nodejs.tar.gz https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz && \
tar xfvz /tmp/nodejs.tar.gz -C /usr/local --strip-components=1 && \
rm -f /tmp/nodejs.tar.gz && \
npm install yarn -g
COPY .docker/php.ini /etc/php/${PHP_VERSION}/cli/conf.d/50-setting.ini
COPY .docker/php.ini /etc/php/${PHP_VERSION}/fpm/conf.d/50-setting.ini
COPY .docker/pool.conf /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf
COPY .docker/nginx.conf /etc/nginx/nginx.conf
COPY .docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 80
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
WORKDIR /app
##
# Production
##
FROM base as prod
# PHP dependencies
COPY composer.json composer.lock symfony.lock ./
RUN set -eux; \
composer install --no-dev --no-autoloader --no-scripts --no-progress --no-suggest
COPY bin bin/
COPY config config/
COPY public public/
COPY src src/
COPY templates templates/
COPY translations translations/
COPY resources resources/
RUN set -eux; \
mkdir -p var/cache var/log; \
chmod +x bin/console; \
composer dump-autoload --no-dev --no-scripts --optimize; \
APP_ENV=prod composer run-script --no-dev post-install-cmd
# Assets dependencies
COPY assets/ ./assets
COPY package.json yarn.lock webpack.config.js ./
RUN set -eux; \
mkdir -p public/build; \
yarn install --no-progress; \
yarn encore production
RUN usermod -u 1000 www-data
And this is the Makefile :
EXEC := docker-compose exec app
PHP := $(EXEC) php -d memory_limit=-1
CONSOLE := $(PHP) bin/console
##
# Service
##
.PHONY: up-dev up-prod up down
up-dev: export ENV := dev
up-dev: up vendor public/build
$(CONSOLE) cache:clear
ifeq ($(shell uname), Linux)
$(EXEC) chown -R $(shell id -u):$(shell id -g) .
endif
up-prod: export ENV := prod
up-prod: up
up-beta: export ENV := beta
up-beta: up
up:
docker-compose -f docker-compose.yml -f docker-compose.$(ENV).yml up -d --build --remove-orphans
I think FROM base as prod is the source of the problem but can't figure out how to fix it and don't want to modify this section since I took the project on the way.
I'm sure LiipImagine is the source of the problem because before installing it make up-prod worked fine !
UPDATE #1
I've tried two updates :
First one : I've deleted this :
RUN set -eux; \
mkdir -p var/cache var/log; \
chmod +x bin/console; \
composer dump-autoload --no-dev --no-scripts --optimize; \
APP_ENV=prod composer run-script --no-dev post-install-cmd
Second one : I've added APP_SECRET like this
RUN set -eux; \
...
APP_ENV=prod APP_SECRET=sameValueAsDotEnv composer run-script --no-dev post-install-cmd
In both cases, the make up-prod works fine with no errors, but I have to run composer install inside the container otherwise depencies are missing ... I really don't get it :(
UPDATE #2
Based on the 1st part of Update #1, I've added this to the up section of Makefile :
$(EXEC) composer install --no-interaction
Now make up-prod is ok, but I still can't find the root of the problem !
I see the error:
Environment variable not found: "APP_SECRET".
First of all, check your .env and .env.loc files include this variable. I guess, that in DEV mode APP_SECRET is set up randomly, but it must be specified explicitly in the PROD.
Secondly, pay attention that DEV and PROD install dependencies slightly different:
if [ "$APP_ENV" = 'prod' ]; then
composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction
else
composer install --prefer-dist --no-progress --no-suggest --no-interaction
fi
Hope, it will give you the right direction.
Well it works after I've added APP_SECRET like this
RUN set -eux; \
...
APP_ENV=prod APP_SECRET=123 composer run-script --no-dev post-install-cmd
Inside the container the APP_SECRET env variable contains the value defined in .env file not 123 ! I really don't understand why I have to add APP_SECRET before composer !
I am using a docker container to execute a python script located at my host machine. The script should make a new directory at a target location.
When the target location is located under $HOME or $HOME/*, everything works. However, when I want to create a directory at /media/my_name/external_drive, the terminal says that PermissionError: [Errno 13] Permission denied: '/media/my_name'
Here is the code I run
sudo docker-compose run --rm --user="$(id -u):$(id -g)" main process_all.py
Here is docker-compose.yml:
version: '2.3'
services:
main:
build: .
volumes:
- .:/app
- /etc/localtime:/etc/localtime:ro
environment:
- PYTHONIOENCODING=utf_8
init: true
network_mode: host
Here is the dockerfile
FROM ubuntu:16.04
# Install some basic utilities
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
sudo \
git \
bzip2 \
axel \
&& rm -rf /var/lib/apt/lists/*
# Create a working directory
RUN mkdir /app
WORKDIR /app
# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
&& chown -R user:user /app
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
USER user
# All users can use /home/user as their home directory
ENV HOME=/home/user
RUN chmod 777 /home/user
# Install Miniconda
RUN curl -so ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.4.10-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p ~/miniconda \
&& rm ~/miniconda.sh
ENV PATH=/home/user/miniconda/bin:$PATH
# Create a Python 3.6 environment
RUN /home/user/miniconda/bin/conda install conda-build \
&& /home/user/miniconda/bin/conda create -y --name py36 python=3.6.4 \
&& /home/user/miniconda/bin/conda clean -ya
ENV CONDA_DEFAULT_ENV=py36
ENV CONDA_PREFIX=/home/user/miniconda/envs/$CONDA_DEFAULT_ENV
ENV PATH=$CONDA_PREFIX/bin:$PATH
# Ensure conda version is at least 4.4.11
# (because of this issue: https://github.com/conda/conda/issues/6811)
ENV CONDA_AUTO_UPDATE_CONDA=false
RUN conda install -y "conda>=4.4.11" && conda clean -ya
# Install FFmpeg
RUN conda install --no-update-deps -y -c conda-forge ffmpeg=3.2.4 \
&& conda clean -ya
# Install NumPy
RUN conda install --no-update-deps -y numpy=1.13.3 \
&& conda clean -ya
# Install build tools
RUN sudo apt-get update \
&& sudo apt-get install -y build-essential gfortran libncurses5-dev \
&& sudo rm -rf /var/lib/apt/lists/*
# Build and install CDF
RUN cd /tmp \
&& curl -O https://spdf.sci.gsfc.nasa.gov/pub/software/cdf/dist/cdf36_4/linux/cdf36_4-dist-all.tar.gz \
&& tar xzf cdf36_4-dist-all.tar.gz \
&& cd cdf36_4-dist \
&& make OS=linux ENV=gnu CURSES=yes FORTRAN=no UCOPTIONS=-O2 SHARED=yes all \
&& sudo make INSTALLDIR=/usr/local/cdf install
# Install other dependencies from pip
COPY requirements.txt .
RUN pip install -r requirements.txt
# Create empty SpacePy config (suppresses an annoying warning message)
RUN mkdir /home/user/.spacepy && echo "[spacepy]" > /home/user/.spacepy/spacepy.rc
# Copy scripts into the image
COPY --chown=user:user . /app
# Set the default command to python3
CMD ["python3"]
Untested, going by memory but I would debug the issue with an interactive version of your container.
Something like:
sudo docker run -t -i --rm --user="$(id -u):$(id -g)" main /bin/bash
You'll get a bash shell. Then you can debug it by
cd /media
ls -l
What I think you'll find is that the drive is probably not mounted. Or, the user doesn't have permission to access it.
With regards to mounts, either pass it through from the host or create a volume mount. I'm a little bit unsure about what you can do there because since I last used docker many changes around mounting and volume drivers were introduced. But the documentation on the docker website is pretty good. So experiment.
This is the cmd line reference for docker: https://docs.docker.com/engine/reference/run/
The key is to use the -t -i parameters to make it interactive.
When running the alpine docker container and trying to build, I get such error message.
/bin/sh: /etc/init.d/postgresql: not found
This is my Dockerfile:
FROM alpine:3.5
MAINTAINER hoge
ENV LANG en_US.utf8
ENV PHX_PORT 4000
ENV PHX_DBNAME hoge_db
COPY release.tar.gz /
RUN echo 'http://dl-3.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
RUN apk update && apk upgrade && \
apk add --no-cache --virtual .base_deps build-base openssl-dev zlib-dev libxml2-dev wget gnupg ca-certificates && \
apk add --no-cache readline-dev glib-lang libssl1.0 postgresql postgresql-client && \
apk add --update binutils && \
apk add --no-cache sudo && \
apk --purge del .base_deps && \
tar -xzf ./release.tar.gz && \
echo "postgres ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/postgres && \
chmod 600 /etc/sudoers.d/postgres && \
sync && \
/etc/init.d/postgresql setup && \
/etc/init.d/postgresql start && \
readelf -l /etc/init.d/postgresql | grep "program interpreter" && \
psql -U postgres -c "CREATE DATABASE $PHX_DBNAME WITH ENCODING 'UTF8' OWNER=postgres TEMPLATE = template0;"
VOLUME /var/lib/postgresql/data
ENTRYPOINT ["psql", "-U", "postgres"]
EXPOSE 5432
/etc/init.d/postgresql is certainly exists.
I surely confirmed that is exist by actually entering the container.
How should I modify?
You need to add openrc to your list of apk add commands.
Found the solution on a github issue of the same, after inspecting the /etc/init.d/postgresql file and seeing the shebang line reference openrc