Skip to content

Commit

Permalink
Merge pull request #159 from crazy-max/docker-install-colima-args
Browse files Browse the repository at this point in the history
docker(install): allow passing colima start args
  • Loading branch information
crazy-max authored Aug 28, 2023
2 parents c8d666e + 32e2a6b commit 31d5e42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion __tests__/docker/install.test.itg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ describe('install', () => {
jest.resetModules();
process.env = {
...originalEnv,
SIGN_QEMU_BINARY: '1'
SIGN_QEMU_BINARY: '1',
COLIMA_START_ARGS: '--cpu 4 --memory 8 --disk 32 --dns 1.1.1.1 --dns 8.8.8.8 --dns-host example.com=1.2.3.4'
};
});
afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/docker/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ provision:
script: |
mkdir -p /tmp/docker-bins
cd /tmp/docker-bins
wget -qO- "https://download.docker.com/linux/static/{{dockerChannel}}/{{hostArch}}/docker-{{dockerVersion}}.tgz" | tar xvz --strip 1
wget -qO- "https://download.docker.com/linux/static/{{dockerBinChannel}}/{{dockerBinArch}}/docker-{{dockerBinVersion}}.tgz" | tar xvz --strip 1
mv -f /tmp/docker-bins/* /usr/bin/
# Modify ~/.ssh/config automatically to include a SSH config for the virtual machine.
Expand Down
18 changes: 11 additions & 7 deletions src/docker/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ export class Install {
}

await core.group('Creating colima config', async () => {
let daemonConfig = yaml.dump({docker: {}});
let colimaDaemonConfig = {};
if (this.daemonConfig) {
daemonConfig = yaml.dump(yaml.load(JSON.stringify({docker: JSON.parse(this.daemonConfig)})));
colimaDaemonConfig = JSON.parse(this.daemonConfig);
}
const colimaCfg = handlebars.compile(colimaYamlData)({
hostArch: Install.platformArch(),
dockerVersion: this._version,
dockerChannel: this.channel,
daemonConfig: daemonConfig
daemonConfig: yaml.dump(yaml.load(JSON.stringify({docker: colimaDaemonConfig}))),
dockerBinVersion: this._version,
dockerBinChannel: this.channel,
dockerBinArch: Install.platformArch()
});
core.info(`Writing colima config to ${path.join(colimaDir, 'colima.yaml')}`);
fs.writeFileSync(path.join(colimaDir, 'colima.yaml'), colimaCfg);
Expand Down Expand Up @@ -180,8 +180,12 @@ export class Install {
};

await core.group('Starting colima', async () => {
const colimaStartArgs = ['start', '--very-verbose'];
if (process.env.COLIMA_START_ARGS) {
colimaStartArgs.push(process.env.COLIMA_START_ARGS);
}
try {
await Exec.exec('colima', ['start', '--very-verbose'], {env: envs});
await Exec.exec(`colima ${colimaStartArgs.join(' ')}`, [], {env: envs});
} catch (e) {
const haStderrLog = path.join(os.homedir(), '.lima', 'colima', 'ha.stderr.log');
if (fs.existsSync(haStderrLog)) {
Expand Down

0 comments on commit 31d5e42

Please sign in to comment.