Skip to content

Commit e5df35a

Browse files
Add build files
1 parent a1ad7a2 commit e5df35a

5 files changed

Lines changed: 65 additions & 4 deletions

File tree

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
**/secrets.dev.yaml
2323
**/values.dev.yaml
2424
LICENSE
25-
README.md
25+
README.md
26+
**/out
27+
package-lock.json

.github/workflows/build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches: [ "main", "build" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
push_to_registry:
13+
name: Push Docker image to Docker Hub
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out the repo
17+
uses: actions/checkout@v3
18+
19+
- name: Log in to Docker Hub
20+
uses: docker/login-action@v2.1.0
21+
with:
22+
username: ${{ secrets.DOCKER_USERNAME }}
23+
password: ${{ secrets.DOCKER_PASSWORD }}
24+
- name: Extract metadata (tags, labels) for Docker
25+
id: meta
26+
uses: docker/metadata-action@v4.3.0
27+
with:
28+
images: trfc/github-teams-user-sync
29+
- name: Build and push Docker image
30+
uses: docker/build-push-action@v3.3.0
31+
with:
32+
context: .
33+
push: true
34+
tags: ${{ steps.meta.outputs.tags }}
35+
labels: ${{ steps.meta.outputs.labels }}
36+
file: Dockerfile

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM node:18 AS Build
2+
ARG NPM_REGISTRY
3+
WORKDIR /usr/src/app
4+
COPY . .
5+
RUN npm config set registry ${NPM_REGISTRY} && \
6+
npm install && \
7+
npm run build && \
8+
npm ci --omit=dev
9+
10+
FROM node:18-alpine
11+
12+
COPY --chown=node --from=Build /usr/src/app/package.json /usr/src/app/package.json
13+
COPY --chown=node --from=Build /usr/src/app/node_modules /usr/src/app/node_modules
14+
COPY --chown=node --from=Build /usr/src/app/out/src/ /usr/src/app/out/src/
15+
16+
USER node
17+
18+
WORKDIR /usr/src/app
19+
20+
CMD npm run start

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"name": "teams-sync-rewrite",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "index.js",
5+
"main": "app.ts",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"start": "nodemon",
8+
"dev": "nodemon",
9+
"start": "node ./out/src/app.js",
10+
"build": "tsc && shx cp ./src/openapi.yaml ./out/src/openapi.yaml",
911
"openapi": "npx -y openapi-to-ts -i ./src/openapi.yaml -o ./src/types/sync-models.d.ts",
1012
"play": "ts-node playground.ts"
1113
},
@@ -17,6 +19,7 @@
1719
"@types/ldapjs": "^2.2.5",
1820
"@types/swagger-ui-express": "^4.1.3",
1921
"nodemon": "^2.0.21",
22+
"shx": "^0.3.4",
2023
"ts-node": "^10.9.1",
2124
"typescript": "^5.0.2"
2225
},
@@ -38,6 +41,6 @@
3841
"ignore": [
3942
"src/**/*.spec.ts"
4043
],
41-
"exec": "ts-node ./src/index.ts"
44+
"exec": "ts-node ./src/app.ts"
4245
}
4346
}
File renamed without changes.

0 commit comments

Comments
 (0)