GithubHelp home page GithubHelp logo

juliangut / docker-phpdev Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 2.0 392 KB

PHP/PHP-FPM/Jenkins Docker image for development/CI, based on Alpine Linux for minimal size

Home Page: https://hub.docker.com/r/juliangut/phpdev/

License: BSD 3-Clause "New" or "Revised" License

Shell 8.22% PHP 34.25% Twig 45.68% Makefile 11.85%
alpine docker php phpstorm xdebug

docker-phpdev's People

Contributors

dependabot[bot] avatar juliangut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-phpdev's Issues

Jenkins version

Add a Jenkins version to be used as slave agent (jenkins user, sshd, ...)

Auto update executing user UID/GID

When mount /app will have host ownership and permissions, it can be used in entry-point to automatically alter running user UID/GID

This should be done on the executing user, other than root

  • In fpm containers should be php-fpm (create home dir and allow prompt)
  • In jenkins containers should be jenkins (create home dir)
  • In cli containers a new user cli should be created

In all cases this user should be the default executing inside the container by USER username at the end of Dockerfile

Considerations:

  • official PHP alpine images already have a www-data user and group, consider reusing those instead of creating new ones (usermod in alpine?)
  • docker-entry needs root access to manipulate ini files, user should be added to sudo loop
  • composer global packages should be located in user's home (currently in root's)
  • documentation examples assigning user's UID/GID are not needed
  • documentation environment variables on user's UID/GID are not nedeed

runtime configure opcache

Similarly to #21

Include and use env vars for opcache

opcache.validate_timestamps = ${OPCACHE_VALIDATE_TIMESTAMP}
opcache.memory_consumption = ${OPCACHE_MEMORY_CONSUMPTION}
opcache.max_accelerated_files = ${OPCACHE_MAX_ACCELERATED_FILES}

extra: reduce default max_accelerated_files

Update sshd configuration

mkdir /var/run/sshd and sed /etc/ssh/sshd_config

PermitRootLogin no
RSAAuthentication yes
PasswordAuthentication no
SyslogFacility AUTH
LogLevel INFO

Log to stdout

Environment variable to configure all logging to stdout

errors when running docker in Jenkins pipeline

I've created a simple pipeline as follows and I can see in the log it pulling the container but it fails with errors as outlined below. Hoping you can provide some guidance and perhaps a README specific to gettings started with Jenkins is a next step.

pipeline {
	agent {
		docker {
			image 'juliangut/phpdev:jenkins-latest'
		}
	}
	stages {
		stage('Install') {
			steps {
				sh 'php -v'
				sh 'composer -V'
			
			}
		}
	}
}

Here is the error output (I have obfuscated the repository name to SSS/SSS).

Push event to branch main
11:53:33 Connecting to https://api.github.com using blacknell/******
Obtained Jenkinsfile from 2ca8389e3142b60e6e830dc466f7a610a577f9fe
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/u-there_SSS_main
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
using credential c19b3c6f-SSS
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/SSS/SSS.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/SSS/SSS.git
 > git --version # timeout=10
 > git --version # 'git version 2.20.4'
using GIT_ASKPASS to set credentials 
 > git fetch --no-tags --force --progress -- https://github.com/SSSS/SSS.git +refs/heads/main:refs/remotes/origin/main # timeout=10
Checking out Revision 2ca8389e3142b60e6e830dc466f7a610a577f9fe (main)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 2ca8389e3142b60e6e830dc466f7a610a577f9fe # timeout=10
Commit message: "Update Jenkinsfile"
 > git rev-list --no-walk 51b20ca213d9d04140ba460dcf5b2494741b1ba1 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . juliangut/phpdev:jenkins-latest
.
[Pipeline] withDockerContainer
Jenkins seems to be running inside container c259aadf1dfdb7145fa9e202404a388e48e845ac0c95de427769a3251adc14b4
but /var/jenkins_home/workspace/u-there_SSS_main could not be found among []
but /var/jenkins_home/workspace/u-there_SSS_main@tmp could not be found among []
$ docker run -t -d -u 1000:1000 -w /var/jenkins_home/workspace/u-there_SSS_main -v /var/jenkins_home/workspace/u-there_SSS_main:/var/jenkins_home/workspace/u-there_SSS_main:rw,z -v /var/jenkins_home/workspace/u-there_SSS_main@tmp:/var/jenkins_home/workspace/u-there_SSS_main@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** juliangut/phpdev:jenkins-latest cat
$ docker top c88babf1ca4922521d4fa23709aaec90cb1e6671bcf3c7fadf0bf25a054e52bd -eo pid,comm
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

GitHub has been notified of this commit’s build result

java.io.IOException: Failed to run top 'c88babf1ca4922521d4fa23709aaec90cb1e6671bcf3c7fadf0bf25a054e52bd'. Error: Error response from daemon: Container c88babf1ca4922521d4fa23709aaec90cb1e6671bcf3c7fadf0bf25a054e52bd is not running
	at org.jenkinsci.plugins.docker.workflow.client.DockerClient.listProcess(DockerClient.java:145)
	at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:199)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
	at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:126)
	at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
	at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:114)
	at org.jenkinsci.plugins.docker.workflow.declarative.DockerPipelineScript.runImage(DockerPipelineScript.groovy:57)
	at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.configureRegistry(AbstractDockerPipelineScript.groovy:73)
	at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.run(AbstractDockerPipelineScript.groovy:51)
	at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.checkoutAndRun(CheckoutScript.groovy:61)
	at ___cps.transform___(Native Method)
	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
	at sun.reflect.GeneratedMethodAccessor262.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

Use env vars on ini files

Instead of managing in docker-entrypoint, set them on dockerfile and use them in xdebug ini file

xdebug.remote_autostart = ${XDEBUG_REMOTE_AUTOSTART}
xdebug.remote_port = ${XDEBUG_REMOTE_PORT}
xdebug.profiler_enable = ${XDEBUG_PROFILER_ENABLE}
xdebug.auto_trace = ${XDEBUG_AUTO_TRACE}
xdebug.idekey = ${XDEBUG_IDE_KEY}

keep XDEBUG_REMOTE_HOST and XDEBUG_FILE_LINK_FORMAT as those get some parsing

There is a problem with the directory /app/public

$ docker-compose up
Creating network "dockerlaravel_default" with the default driver
Creating dockerlaravel_app_1 ... done
Attaching to dockerlaravel_app_1
app_1 | Directory /app/public does not exist.
dockerlaravel_app_1 exited with code 1
Directory /app/public does not exist.

set system timezone

RUN apk --update add tzdata
&& cp /usr/share/zoneinfo/UTC /etc/localtime
&& echo 'UTC' > /etc/timezone
&& apk del tzdata

add alpine community repository

echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.