diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..26bdbaa --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,22 @@ +name: Build and release + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Add SSH identity key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts + + - name: Build & upload image + run: ./upload_to_server.sh ${{ secrets.SERVER_IP }} ${{ secrets.SSH_USER }} + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a053d35 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM oven/bun:alpine + +WORKDIR /app + +COPY entrypoint.sh ./ +COPY package.json ./ +COPY bun.lockb ./ +COPY src ./src + +RUN bun install + +EXPOSE 3000 + +ENTRYPOINT ["bun", "run", "start"] + diff --git a/upload_to_server.sh b/upload_to_server.sh new file mode 100755 index 0000000..1662c1a --- /dev/null +++ b/upload_to_server.sh @@ -0,0 +1,9 @@ +ip=$1 +user=$2 + +docker buildx build --platform linux/amd64 . --tag amiopen:latest +docker save -o amiopen.tar amiopen:latest + +scp amiopen.tar $user@$ip:~/amiopen/amiopen.tar +ssh $user@$ip "cd ~/amiopen && docker container stop amiopen && docker container rm amiopen && docker load -i amiopen.tar && docker compose up -d" +