Skip to content

Commit 9c91fa6

Browse files
committed
feat: move to github docker registry
1 parent b355bb8 commit 9c91fa6

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

.cursor/rules/poinz.mdc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
---
22
description:
3-
globs: client/**/*.js,client/**/*.jsx
4-
alwaysApply: false
3+
globs:
4+
alwaysApply: true
55
---
66
# Poinz rules
77

88
- we are still using javascript
99
- if you are working on a js file, do not create a ts file, do everything in the javascript file
1010
- if you are creating new files you must use typescript
1111

12-
- NEVER FINISH BEFORE YOU ARE NOT FINISHED, I DO NOT WANT TO HEAR "should I continue?"
12+
- NEVER FINISH BEFORE YOU ARE NOT FINISHED, I DO NOT WANT TO HEAR "should I continue?"
13+
14+
- DO NOT EVER SUMMARISE WHAT YOU DID, I SEE IT IN THE CODE CHANGES

.github/workflows/development.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ jobs:
2828
run: npm test
2929

3030
- name: build app & docker image
31+
env:
32+
DOCKER_REGISTRY: ghcr.io
33+
DOCKER_USERNAME: ${{ github.repository_owner }}
3134
run: npm run build:dockerImage

.github/workflows/master.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
jobs:
1313
build:
1414
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
1518

1619
steps:
1720
- uses: actions/checkout@v3
@@ -28,15 +31,21 @@ jobs:
2831
- name: run all tests
2932
run: npm test
3033

34+
- name: Log in to GitHub Container Registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
3141
- name: build app & docker image
42+
env:
43+
DOCKER_REGISTRY: ghcr.io
44+
DOCKER_USERNAME: ${{ github.repository_owner }}
3245
run: npm run build:dockerImage
3346

34-
# push docker image to repo (the --all-tags flag was introduced in version v20.10, older versions pushed all images automatically if no tag was provided)
35-
- name: push docker image
47+
- name: Push Docker image
3648
env:
37-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
38-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
49+
DOCKER_USERNAME: ${{ github.repository_owner }}
3950
run: |
40-
docker -v;
41-
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
42-
docker image push --all-tags "${DOCKER_USERNAME}/poinz" || docker image push "${DOCKER_USERNAME}/poinz";
51+
docker image push --all-tags "ghcr.io/${DOCKER_USERNAME,,}/poinz" || docker image push "ghcr.io/${DOCKER_USERNAME,,}/poinz"

build/dockerImage.mjs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,23 @@ async function buildImage() {
3333
} (git-tags: ${gitInfo.tags.join(' ')})`
3434
);
3535

36-
const user = process.env.DOCKER_USERNAME || 'xeronimus';
37-
const userAndProject = `${user}/poinz`;
36+
if (!process.env.DOCKER_REGISTRY) {
37+
throw new Error('DOCKER_REGISTRY environment variable must be set');
38+
}
39+
if (!process.env.DOCKER_USERNAME) {
40+
throw new Error('DOCKER_USERNAME environment variable must be set');
41+
}
42+
43+
const registry = process.env.DOCKER_REGISTRY;
44+
const user = process.env.DOCKER_USERNAME.toLowerCase();
45+
const userAndProject = `${registry}/${user}/poinz`;
3846
const tags = [`${userAndProject}:latest`, HEROKU_DEPLOYMENT_TAG];
3947
gitInfo.tags.forEach((gitTag) => tags.push(`${userAndProject}:${gitTag}`));
4048
const cmdArgs = `build ${tags.map((tg) => '-t ' + tg).join(' ')} --network=host .`;
4149

42-
console.log(` $ docker ${cmdArgs}`); // will be something like : docker build -t xeronimus/poinz:latest -t registry.heroku.com/poinz/web .
50+
console.log(` $ docker ${cmdArgs}`);
4351

4452
return spawnAndPrint('docker', cmdArgs.split(' '), {cwd: path.resolve(dirname, '..')});
45-
46-
console.log(
47-
'Done.\ndocker run -e NODE_ENV=development -p 3000:3000 --name poinz_local -d xeronimus/poinz'
48-
);
4953
}
5054

5155
function getGitInformation() {

0 commit comments

Comments
 (0)