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

Migrate teraslice image from docker.hub to ghcr.io registry #3699

Merged
merged 8 commits into from
Jul 25, 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
14 changes: 4 additions & 10 deletions .github/workflows/publish-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ jobs:
- name: Verify npm authentication
run: npm whoami

# we login to docker to publish new teraslice image
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Check out code
uses: actions/checkout@v4

Expand All @@ -45,14 +38,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
steps:
# we login to docker to publish new teraslice image
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Check out code
uses: actions/checkout@v4
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
steps:
- name: Check out code
uses: actions/checkout@v4
Expand All @@ -115,7 +115,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
# opensearch is finiky, keep testing others if it fails
fail-fast: false
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
search-version: [elasticsearch6, elasticsearch7, opensearch1, opensearch2]
steps:
- name: Check out code
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
# opensearch is finiky, keep testing others if it fails
fail-fast: false
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
search-version: [elasticsearch6, elasticsearch7, opensearch1, opensearch2]
steps:
- name: Check out code
Expand Down Expand Up @@ -261,7 +261,7 @@ jobs:
# opensearch is finiky, keep testing others if it fails
fail-fast: false
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
search-version: [elasticsearch6, elasticsearch7, opensearch1, opensearch2]
steps:
- name: Check out code
Expand Down Expand Up @@ -320,7 +320,7 @@ jobs:
# opensearch is finiky, keep testing others if it fails
fail-fast: false
matrix:
node-version: [18, 20, 22.4.1]
node-version: [18, 20, 22]
search-version: [elasticsearch6, elasticsearch7, opensearch1, opensearch2]
steps:
- name: Check out code
Expand Down Expand Up @@ -383,7 +383,7 @@ jobs:
# opensearch is finiky, keep testing others if it fails
fail-fast: false
matrix:
node-version: [18, 22.4.1]
node-version: [18, 22]
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down Expand Up @@ -450,7 +450,7 @@ jobs:
# opensearch is finiky, keep testing others if it fails
fail-fast: false
matrix:
node-version: [18, 22.4.1]
node-version: [18, 22]
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NODE_VERSION is set by default in the config.ts, the following value will only
# be used if you build images by default with docker build
ARG NODE_VERSION=18
FROM terascope/node-base:${NODE_VERSION}
FROM ghcr.io/terascope/node-base:${NODE_VERSION}

ARG TERASLICE_VERSION
ARG BUILD_TIMESTAMP
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NODE_VERSION is set by default in the config.ts, the following value will only
# be used if you build images by default with docker build
ARG NODE_VERSION=18
FROM terascope/node-base:${NODE_VERSION}
FROM ghcr.io/terascope/node-base:${NODE_VERSION}

ENV NODE_ENV production

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
},
"docker": {
"registries": [
"terascope/teraslice"
"ghcr.io/terascope/teraslice"
]
},
"npm": {
Expand Down
8 changes: 6 additions & 2 deletions packages/scripts/src/helpers/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
remoteDockerImageExists,
dockerBuild,
dockerPush,
yarnPublishV2
yarnPublishV2,
getNodeVersionFromImage
} from '../scripts';
import { getRootInfo, getDevDockerImage, formatList } from '../misc';
import signale from '../signale';
Expand Down Expand Up @@ -94,7 +95,10 @@ async function publishToDocker(options: PublishOptions) {
let err: any|undefined;
for (const registry of registries) {
let imageToBuild = '';
const nodeVersionSuffix = `nodev${options.nodeVersion}`;

/// NOTE: When publishing images, we always want the full node semver version
/// on the tag
const nodeVersionSuffix = `node${await getNodeVersionFromImage(devImage)}`;

if (options.type === PublishType.Latest) {
imageToBuild = `${registry}:latest-${nodeVersionSuffix}`;
Expand Down
12 changes: 12 additions & 0 deletions packages/scripts/src/helpers/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ export async function dockerTag(from: string, to: string): Promise<void> {
signale.success(`Image ${from} re-tagged as ${to}`);
}

export async function getNodeVersionFromImage(image: string): Promise<string> {
try {
const { stdout } = await execa(
'docker',
['run', image, 'node', '-v']
);
return stdout;
} catch (err) {
throw new Error(`Unable to get node version from image due to Error: ${err}`);
}
}

export async function getContainerInfo(name: string): Promise<any> {
const result = await exec({
cmd: 'docker',
Expand Down
Loading