Skip to content

Commit

Permalink
feat: add Dockerfile for releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jun 6, 2024
1 parent bb87460 commit 95cab48
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 55 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/deploy-client.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- uses: docker/build-push-action@v5
with:
push: true
build-args: |
VERSION=${{ env.VERSION }}
tags: frourio/magnito:latest,frourio/magnito:${{ env.VERSION }}
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY package.json package-lock.json .
RUN npm ci

COPY client/package.json client/package-lock.json ./client/
RUN npm ci --prefix client

COPY server/package.json server/package-lock.json ./server/
RUN npm ci --prefix server

COPY . .
ARG VERSION

RUN cp client/.env.example client/.env
RUN cp server/.env.example server/.env
RUN npm run batch:writeVersion -- $VERSION
RUN npm run build

CMD npm start
9 changes: 9 additions & 0 deletions batches/writeVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');

const version = process.argv[2];
const jsonPath = path.join(process.cwd(), 'package.json');

assert(/\d+\.\d+\.\d+/.test(version));
fs.writeFileSync(jsonPath, JSON.stringify({ ...require(jsonPath), version }, null, 2), 'utf8');
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
"dev": "run-p dev:*",
"dev:client": "npm run dev --prefix client",
"dev:server": "npm run dev --prefix server",
"build": "run-p build:*",
"build:client": "npm run build --prefix client",
"build:server": "npm run build --prefix server",
"generate": "run-p generate:*",
"generate:client": "npm run generate --prefix client",
"generate:server": "npm run generate --prefix server",
"batch:writeVersion": "node batches/writeVersion.js",
"lint": "run-p lint:*",
"lint:client": "npm run lint:fix --prefix client",
"lint:server": "npm run lint:fix --prefix server",
Expand Down

0 comments on commit 95cab48

Please sign in to comment.