How to use @nomiclabs/buidler-docker - 7 common examples

To help you get started, we’ve selected a few @nomiclabs/buidler-docker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function pullImageIfNecessary(
  docker: BuidlerDocker,
  image: Image,
  cachePath: string
) {
  if (!(await docker.hasPulledImage(image))) {
    console.log(
      `Pulling Docker image ${BuidlerDocker.imageToRepoTag(image)}...`
    );

    await docker.pullImage(image);

    console.log(`Image pulled`);
  } else {
    await checkForImageUpdates(docker, image, cachePath);
  }
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function checkForImageUpdates(
  docker: BuidlerDocker,
  image: Image,
  cachePath: string
) {
  if (!(await shouldCheckForUpdates(image, cachePath))) {
    return;
  }

  if (!(await docker.isImageUpToDate(image))) {
    console.log(
      `Updating Docker image ${BuidlerDocker.imageToRepoTag(image)}...`
    );

    await docker.pullImage(image);

    console.log(`Image updated`);
  }

  await saveLastUpdateCheckDate(image, cachePath);
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
export async function compile(vyperConfig: VyperConfig, paths: ProjectPaths) {
  const vyperVersion = vyperConfig.version;

  const dockerImage = {
    repository: VYPER_DOCKER_REPOSITORY,
    tag: vyperVersion
  };

  await validateDockerIsInstalled();

  const docker = await handleCommonErrors(BuidlerDocker.create());

  await handleCommonErrors(
    pullImageIfNecessary(docker, dockerImage, paths.cache)
  );

  const files = await getVyperSources(paths);

  let someContractFailed = false;

  for (const file of files) {
    const pathFromCWD = path.relative(process.cwd(), file);
    const pathFromSources = path.relative(paths.sources, file);

    if (await isAlreadyCompiled(file, paths, vyperVersion, files)) {
      console.log(pathFromCWD, "is already compiled");
      continue;
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function getLastUpdateCheckDate(
  image: Image,
  cachePath: string
): Promise {
  const file = path.join(cachePath, VYPER_DOCKER_IMAGES_LAST_UPDATE_CHECK_FILE);
  if (!(await fsExtra.pathExists(file))) {
    return undefined;
  }

  const updates = await fsExtra.readJSON(file);
  return updates[BuidlerDocker.imageToRepoTag(image)];
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
if (error instanceof DockerHubConnectionError) {
      throw new BuidlerPluginError(
        `Error connecting to Docker Hub.
Please check your internet connection.`,
        error
      );
    }

    if (error instanceof DockerServerError) {
      throw new BuidlerPluginError("Docker error", error);
    }

    if (error instanceof ImageDoesntExistError) {
      throw new BuidlerPluginError(
        `Docker image ${BuidlerDocker.imageToRepoTag(
          error.image
        )} doesn't exist.
Make sure you chose a valid Vyper version.`
      );
    }

    throw error;
  }
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function saveLastUpdateCheckDate(image: Image, cachePath: string) {
  let updates: { [repoTag: string]: number };

  const file = path.join(cachePath, VYPER_DOCKER_IMAGES_LAST_UPDATE_CHECK_FILE);
  if (!(await fsExtra.pathExists(file))) {
    updates = {};
  } else {
    updates = await fsExtra.readJSON(file);
  }

  updates[BuidlerDocker.imageToRepoTag(image)] = +new Date();

  await fsExtra.ensureDir(path.dirname(file));
  await fsExtra.writeJSON(file, updates);
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function validateDockerIsInstalled() {
  if (!(await BuidlerDocker.isInstalled())) {
    throw new BuidlerPluginError(
      `Docker Desktop is not installed.
Please install it by following the instructions on https://www.docker.com/get-started`
    );
  }
}

@nomiclabs/buidler-docker

A library to manage Docker from Buidler plugins

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis