Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass on extra parameters to the Docker container #19

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions testrunner/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ executable: "sitespeed.io"
# If you run sitespeed.io using Docker this is the container that is used.
# If you use the latest, make sure to docker pull the container once a day
# to get the latest version
# extraparameters will be passed omn to Docker, between docker run and the container name
docker:
container: "sitespeedio/sitespeed.io:latest"
extraparameters:
14 changes: 14 additions & 0 deletions testrunner/src/testrunners/docker-testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { queueHandler } from '../queue/queuehandler.js';

const { join } = path;

const parseDockerExtraParameters = parameters => {
if (!parameters) {
return [];
}
return parameters.split(' ').map(parameter => parameter.trim());
};

export default async function runJob(job) {
const logger = log.getLogger(`sitespeedio.dockertestrunner.${job.id}`);
const dockerLogger = log.getLogger(
Expand All @@ -21,6 +28,10 @@ export default async function runJob(job) {
const baseWorkingDirectory = os.tmpdir();
const dockerContainer = nconf.get('docker:container');

const dockerExtraParameters = parseDockerExtraParameters(
nconf.get('docker:extraparameters')
);

workingDirectory = join(baseWorkingDirectory, job.queue.name, job.id);
const insideDockerDirectory = join(
'/sitespeed.io/',
Expand All @@ -45,6 +56,7 @@ export default async function runJob(job) {
const parameters = setupDockerParameters(
job,
dockerContainer,
dockerExtraParameters,
baseWorkingDirectory,
insideDockerDirectory,
configFileName,
Expand Down Expand Up @@ -136,6 +148,7 @@ async function handleScriptingFile(job, workingDirectory) {
function setupDockerParameters(
job,
dockerContainer,
dockerExtraParameters,
baseWorkingDirectory,
insideDockerDirectory,
configFileName,
Expand All @@ -146,6 +159,7 @@ function setupDockerParameters(
'--rm',
'--volume',
`${baseWorkingDirectory}:/sitespeed.io`,
...dockerExtraParameters,
dockerContainer,
'--config',
join(insideDockerDirectory, configFileName),
Expand Down
3 changes: 2 additions & 1 deletion testrunner/src/validateconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const loggingSchema = Joi.object({

// Docker schema
const dockerSchema = Joi.object({
container: Joi.string().optional()
container: Joi.string().optional(),
extraparameters: Joi.string().allow(null).optional()
});

// Complete config schema
Expand Down