-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker - Client and common compose (#20)
* Simple Dockerfile for client * Client Docker image is Done & Neat * Svelte installed as normal dep :( No audit during build * Moving compose out, .dockerignores * Images workflow for Docker images & ECR * Adding DEV.md to trigger build * Updating aws region * Setting up dependant CI jobs * Depend on server test suite * Fixing multi file COPY-ies * Docker image publish only from main branch * Some more to README, whitespaces * Readme tweak * Fixing a silly link in readme * New packege-lock after merge * One more readme link try * Directly using Vite for build and package sveltejs/kit#5184 * Adding node 18 workflow Skipping workflows not related to the PR * Remove test workflow config omit=dev in client dockerfile
- Loading branch information
Showing
17 changed files
with
1,767 additions
and
1,795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Build & Publish Docker Images | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-client: | ||
name: Publish Client image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Wait for Client checks to succeed | ||
uses: lewagon/[email protected] | ||
with: | ||
ref: ${{ github.ref }} | ||
check-name: "Build and Check Client (18.x)" | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Authenticate into AWS | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-central-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Client - Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: rezsi-client | ||
IMAGE_TAG: latest | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./client | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
publish-server: | ||
name: Publish Server image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Wait for Server checks to succeed | ||
uses: lewagon/[email protected] | ||
with: | ||
ref: ${{ github.ref }} | ||
check-name: "Server Test Suite" | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Authenticate into AWS | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-central-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Server - Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: rezsi-server | ||
IMAGE_TAG: latest | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./server | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Backend dev setup | ||
## Prerequisites | ||
- rustup | ||
- Docker / MySQL / PostgreSQL | ||
|
||
## Starting a dev database | ||
- There are two options: | ||
- local mysql database | ||
- Run the `server/init.sql` file, which creates the necessary database structure | ||
- mysql database in a docker container with docker-compose | ||
- Run `docker-compose up -d database` and a database will be available at the 3306 port, already initialized | ||
|
||
## Running server | ||
- Build and run with `cargo run`, it will automatically run database migrations | ||
- When developing use `cargo watch -x run` for hot-reloading, provided `cargo-watch` is installed | ||
- To manipulate migrations, refer to the README.md in the `server/migration` directory and use the CLI tool | ||
- It uses the outer `.env` file for the connection string but it can be supplied with it's own file in the `server/migration` directory if needed | ||
|
||
# Frontend dev setup | ||
## Prerequisites | ||
- Docker | ||
- node 16.7 or higher | ||
- v16.14.0 ✅ | ||
- v18.4.0 ✅ | ||
- npm v7 or higher | ||
- 8.4.1 ✅ | ||
|
||
## Starting backend for client | ||
- To run the complete backend (database & server), use `docker-compose up -d database server`, the database will be available at port 3306 and the server on 8000 | ||
- The build will take some time at first and on changes, consequent runs will be much faster thanks to docker caching | ||
- It can be used as a backend for frontend development, the server is built in release mode, so it is smaller and highly optimized | ||
|
||
## Starting Svelte dev server | ||
- `cd ./client` | ||
- `npm i` | ||
- `npm run dev` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
# veryrezsi | ||
# 💲 VeryRezsi 💲 | ||
###### Status | ||
![Docker Build](https://github.com/szattila98/veryrezsi/actions/workflows/images.yml/badge.svg) | ||
## Brief | ||
Subscription and expense calculator web-application. | ||
|
||
# Usage | ||
|
||
## Prerequisites | ||
|
||
- npm v7 or higher | ||
- 8.4.1 ✅ | ||
- node v14 or higher | ||
- v16.14.0 ✅ | ||
Powered by SvelteKit on client side, and Rust on server side. | ||
|
||
## Development | ||
- `cd ./veryrezsi/client` | ||
- `npm i` | ||
- `npm run dev` | ||
Refer to [DEV.md](../main/DEV.md) file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Dockerfile | ||
.dockerignore | ||
.gitignore | ||
*/node_modules | ||
*/npm-debug.log | ||
.svelte-kit | ||
build | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Stage BUILD | ||
FROM node:18-alpine | ||
|
||
WORKDIR /app | ||
COPY . ./ | ||
|
||
RUN npm ci --no-audit | ||
RUN npm run build | ||
|
||
# Stage RUN | ||
FROM node:18-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=0 /app/package*.json ./ | ||
COPY --from=0 /app/build ./ | ||
|
||
# clean install dependencies, no devDependencies, no prepare script | ||
RUN npm ci --omit=dev --ignore-scripts --no-audit | ||
|
||
EXPOSE 3000 | ||
CMD ["node", "./index.js"] |
Oops, something went wrong.