Skip to content

Commit 62c8838

Browse files
committed
feat: add start script to API package.json
- Introduced a new "start" script to the API's package.json for easier execution of the application using Bun.
1 parent 69a69f9 commit 62c8838

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.github/workflows/push-api.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish API Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'apps/api/**'
10+
11+
jobs:
12+
push_to_registry:
13+
name: Push Docker image to Docker Hub
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
attestations: write
19+
id-token: write
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v4
23+
with:
24+
ssh-key: ${{ secrets.SSH_KEY }}
25+
- uses: oven-sh/setup-bun@v2
26+
name: Setup bun
27+
with:
28+
bun-version: latest
29+
- uses: fregante/setup-git-user@v2
30+
name: Setup git user
31+
- name: Install dependencies
32+
working-directory: ./apps/api
33+
run: |
34+
bun install
35+
- name: Read version from package.json
36+
id: get_version
37+
working-directory: ./apps/api
38+
run: |
39+
VERSION=$(jq -r '.version' package.json)
40+
echo "Current version: $VERSION"
41+
echo "version=$VERSION" >> $GITHUB_ENV
42+
- name: Log in to Docker Hub
43+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
44+
with:
45+
username: ${{ secrets.DOCKER_USERNAME }}
46+
password: ${{ secrets.DOCKER_PASSWORD }}
47+
- name: Extract metadata (tags, labels) for Docker
48+
id: meta
49+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
50+
with:
51+
images: stormix/deadlock-mods-api
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
- name: Build and push Docker image
55+
id: push
56+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
57+
with:
58+
context: .
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max
61+
file: ./apps/api/Dockerfile
62+
push: true
63+
tags: |
64+
${{ secrets.DOCKER_USERNAME }}/deadlock-mods-api:${{ env.version }}
65+
${{ secrets.DOCKER_USERNAME }}/deadlock-mods-api:latest
66+
labels: ${{ steps.meta.outputs.labels }}

apps/api/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM oven/bun:1.1.38
2+
3+
WORKDIR /usr/src/app
4+
5+
RUN apt-get -y update; apt-get -y install curl
6+
ARG NODE_VERSION=22.11.0
7+
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
8+
RUN bash n $NODE_VERSION
9+
RUN rm n
10+
RUN npm install -g n
11+
12+
COPY apps/api .
13+
14+
RUN bun install
15+
RUN bunx prisma generate
16+
17+
EXPOSE 9000
18+
19+
ENTRYPOINT [ "bun", "start" ]

apps/api/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "api",
33
"scripts": {
4+
"start": "bun run src/index.ts",
45
"dev": "bun run --watch src/index.ts",
56
"lint": "eslint ./src/**/*.{ts,tsx} --quiet --fix",
67
"desktop:dev": "pnpm dev"

0 commit comments

Comments
 (0)