Skip to content

Commit f2dab12

Browse files
authored
Merge pull request #302 from rohaizanr/api-publish
Api-publish
2 parents bb86b60 + 9c73602 commit f2dab12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+469
-243
lines changed

README.en.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
![Github issues](https://img.shields.io/github/issues/Dev4w4n/e-masjid.my)
44
![Github last-commit](https://img.shields.io/github/last-commit/Dev4w4n/e-masjid.my)
55

6-
76
<p align="center">
87
<img src="./public-web/src/assets/home/logo.png" alt="E-Masjid.My" width="80" height="80"/>
98
</p>
@@ -17,8 +16,8 @@
1716
<a href='https://demo.e-masjid.my'>Live Demo</a>
1817
</h2><br>
1918

20-
Philosophy
21-
=====
19+
# Philosophy
20+
2221
The main goals for this system are listed below.
2322

2423
**Easy of use**
@@ -37,37 +36,40 @@ The main goals for this system are listed below.
3736

3837
- We should be contributing to the Muslim community, rather than benefiting from them, especially the Masjid.
3938

40-
4139
## Prerequisites
40+
4241
1. GIT https://www.git-scm.com/downloads
4342
2. Docker Desktop https://docs.docker.com/get-docker/
4443
3. Node 20 https://nodejs.org/en/download
4544
4. Go https://go.dev/dl/
4645
5. VSCode https://code.visualstudio.com/download
4746

4847
## Minimum Requirement for System Development
48+
4949
1. Processor: 1.6 GHz or faster 64-bit processor
5050
2. Memory: 8 GB RAM or higher
5151

5252
## Quickstart guide (Docker compose)
53+
5354
### Fork this repo
55+
5456
1. Fork this repo to your personal GitHub account, example `https://github.com/<github-user>/e-masjid.my`, by pressing the Fork button on the top right part of this page.
5557
2. Once done, clone this repo to your computer.
58+
5659
```
5760
git clone https://github.com/<github-user>/e-masjid.my.git
5861
```
62+
5963
3. Once done, navigate to the e-masjid.my folder.
64+
6065
```
6166
cd e-masjid.my
6267
```
68+
6369
4. Follow the instructions below depending on your computer's operating system.
64-
### Linux
65-
```
66-
sh run-dev.sh
67-
```
68-
### Windows - Use Git Bash terminal in VSCode
70+
6971
```
70-
sh run-dev.sh
72+
docker compose up -d
7173
```
7274

7375
This will automatically build all the APIs, and run the docker-compose file where it will spin up 6 containers for the developments environment.
@@ -86,6 +88,5 @@ We love your input! We want to make contributing to this project as easy and tra
8688
- Enhancing features
8789
- Documentation
8890
- Unit testing
89-
90-
Or you would just like to chat with us, find us on [Discord](https://discord.gg/vz4WWM85)
9191

92+
Or you would just like to chat with us, find us on [Discord](https://discord.gg/vz4WWM85)

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<a href='https://demo.e-masjid.my'>Demo Langsung</a>
1919
</h2><br>
2020

21-
Falsafah
22-
=====
21+
# Falsafah
22+
2323
Matlamat-matlamat utama sistem ini ialah seperti berikut.
2424

2525
**Mudah untuk digunakan**
@@ -38,45 +38,49 @@ Matlamat-matlamat utama sistem ini ialah seperti berikut.
3838

3939
- Kita sepatutnya menyumbang kepada komuniti Muslim, terutamanya masjid dan bukan mengambil manfaat daripada mereka.
4040

41-
4241
## Prasyarat
42+
4343
1. GIT https://www.git-scm.com/downloads
4444
2. Docker Desktop https://docs.docker.com/get-docker/
4545
3. Node 20 https://nodejs.org/en/download
4646
4. Go https://go.dev/dl/
4747
5. VSCode https://code.visualstudio.com/download
4848

4949
## Keperluan Minimum Sistem untuk tujuan Pembangunan Sistem
50+
5051
1. Pemproses: 1.6 GHz atau lebih pantas
5152
2. Memori: 8 GB RAM atau lebih tinggi
5253

5354
## Panduan permulaan pantas (Docker compose)
55+
5456
### Fork repo ini
55-
1. *Fork* repo ini ke akaun Github anda, contoh `https://github.com/<github-user>/e-masjid.my`, dengan menekan butang *Fork* di bahagian atas sebelah kanan laman web ini.
56-
2. Setelah selesai *Fork*, *klon* repo ini ke komputer anda.
57+
58+
1. _Fork_ repo ini ke akaun Github anda, contoh `https://github.com/<github-user>/e-masjid.my`, dengan menekan butang _Fork_ di bahagian atas sebelah kanan laman web ini.
59+
2. Setelah selesai _Fork_, _klon_ repo ini ke komputer anda.
60+
5761
```
5862
git clone https://github.com/<github-user>/e-masjid.my.git
5963
```
60-
3. Setelah selesai *klon*, navigasi ke *folder* e-masjid.my.
64+
65+
3. Setelah selesai _klon_, navigasi ke _folder_ e-masjid.my.
66+
6167
```
6268
cd e-masjid.my
6369
```
70+
6471
4. Ikut arahan seterusnya seperti di bawah bergantung kepada sistem pengoperasian komputer anda.
65-
### Linux
66-
```
67-
sh run-dev.sh
68-
```
69-
### Windows - Gunakan terminal Git Bash di VSCode
72+
7073
```
71-
sh run-dev.sh
74+
docker compose up -d
7275
```
7376

74-
Skrip ini akan membina semua API secara automatik dan melaksanakan arahan docker-compose yang akan menghidupkan 6 *container* untuk persekitaran pembangunan.
77+
Skrip ini akan membina semua API secara automatik dan melaksanakan arahan docker-compose yang akan menghidupkan 6 _container_ untuk persekitaran pembangunan.
7578

76-
Apabila kesemua *container* telah hidup, anda boleh menghentikan mana-mana *container* yang tidak diperlukan dalam tugasan anda.
79+
Apabila kesemua _container_ telah hidup, anda boleh menghentikan mana-mana _container_ yang tidak diperlukan dalam tugasan anda.
7780

7881
## Panduan untuk menyumbang
79-
*Fork* repo ini dan hantar *Pull Request* anda.
82+
83+
_Fork_ repo ini dan hantar _Pull Request_ anda.
8084

8185
Kami mahu input anda! Kami ingin menjadikan penyumbangan kepada projek mudah dan telus, sama ada dengan:
8286

@@ -86,8 +90,8 @@ Kami mahu input anda! Kami ingin menjadikan penyumbangan kepada projek mudah dan
8690
- Menambah baik ciri
8791
- Dokumentasi
8892
- Ujian unit
89-
90-
Atau anda ingin berbual dengan kami, cari kami di [Discord](https://discord.gg/k2zGpWTDpe).
9193

94+
Atau anda ingin berbual dengan kami, cari kami di [Discord](https://discord.gg/k2zGpWTDpe).
9295

9396
[![Contributors](https://contrib.rocks/image?repo=Dev4w4n/e-masjid.my)](https://github.com/Dev4w4n/e-masjid.my/graphs/contributors)
97+

api/cadangan-api/.env.dev

Lines changed: 0 additions & 11 deletions
This file was deleted.

api/cadangan-api/.env.prod

Lines changed: 0 additions & 9 deletions
This file was deleted.

api/cadangan-api/Dockerfile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,38 @@ RUN swag init
2323
FROM alpine:latest
2424

2525
# Define build-time argument for GO_ENV
26-
ARG GO_ENV=local
27-
28-
# Set Go environment variables
29-
ENV GO_ENV=$GO_ENV
26+
ENV GO_ENV="docker"
27+
ENV DB_HOST="postgres"
28+
ENV DB_PORT="5432"
29+
ENV DB_USER="pgsql-saas"
30+
ENV DB_PASSWORD="pgsql-saas"
31+
ENV DB_NAME="pgsql-saas"
32+
ENV ALLOWED_ORIGIN="*"
33+
ENV DEPLOY_URL="/"
34+
ENV SERVER_PORT="8083"
35+
ENV API_DOC_URL="http://localhost:4000"
3036

3137
# Set the working directory inside the container
3238
WORKDIR /app
3339

3440
# Copy only the built binary from the builder stage
3541
COPY --from=builder /app/cadangan-api .
36-
COPY --from=builder /app/.env.* .
3742
COPY --from=builder /app/wait-for-it.sh .
3843
COPY --from=builder /app/docs ./docs
3944

4045
# Expose the port that your application will run on
4146
EXPOSE 8080
4247

48+
# Script to dynamically generate .env.docker at runtime
49+
COPY generate-env.sh /docker-entrypoint.d/generate-env.sh
50+
RUN chmod +x /docker-entrypoint.d/generate-env.sh
51+
52+
# Copy the custom entrypoint
53+
COPY entrypoint.sh /entrypoint.sh
54+
RUN chmod +x /entrypoint.sh
55+
56+
# Set the custom entrypoint
57+
ENTRYPOINT ["/entrypoint.sh"]
58+
4359
# Command to run your application
4460
CMD ["./cadangan-api", "-env", "$GO_ENV"]

api/cadangan-api/entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Execute scripts in /docker-entrypoint.d, if any
5+
if [ -d "/docker-entrypoint.d" ]; then
6+
for script in /docker-entrypoint.d/*; do
7+
if [ -x "$script" ]; then
8+
echo "Running $script"
9+
"$script"
10+
else
11+
echo "Skipping $script, not executable"
12+
fi
13+
done
14+
fi
15+
16+
# Pass control to CMD
17+
exec "$@"

api/cadangan-api/generate-env.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
echo "Generating .env.docker..."
2+
cat <<EOF > /app/.env.docker
3+
GO_ENV=${GO_ENV}
4+
DB_HOST=${DB_HOST}
5+
DB_PORT=${DB_PORT}
6+
DB_USER=${DB_USER}
7+
DB_PASSWORD=${DB_PASSWORD}
8+
DB_NAME=${DB_NAME}
9+
ALLOWED_ORIGIN=${ALLOWED_ORIGIN}
10+
DEPLOY_URL=${DEPLOY_URL}
11+
SERVER_PORT=${SERVER_PORT}
12+
API_DOC_URL=${API_DOC_URL}
13+
EOF
14+
15+
echo ".env.docker created with the following content:"
16+
cat /app/.env.docker

api/cadangan-public-api/.env.dev

Lines changed: 0 additions & 11 deletions
This file was deleted.

api/cadangan-public-api/.env.prod

Lines changed: 0 additions & 9 deletions
This file was deleted.

api/cadangan-public-api/Dockerfile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,37 @@ RUN swag init
2323
FROM alpine:latest
2424

2525
# Define build-time argument for GO_ENV
26-
ARG GO_ENV=local
27-
28-
# Set Go environment variables
29-
ENV GO_ENV=$GO_ENV
26+
ENV GO_ENV="docker"
27+
ENV DB_HOST="postgres"
28+
ENV DB_PORT="5432"
29+
ENV DB_USER="pgsql-saas"
30+
ENV DB_PASSWORD="pgsql-saas"
31+
ENV DB_NAME="pgsql-saas"
32+
ENV ALLOWED_ORIGIN="*"
33+
ENV DEPLOY_URL="/"
34+
ENV SERVER_PORT="8084"
35+
ENV API_DOC_URL="http://localhost:4000"
3036

3137
# Set the working directory inside the container
3238
WORKDIR /app
3339

3440
# Copy only the built binary from the builder stage
3541
COPY --from=builder /app/cadangan-public-api .
36-
COPY --from=builder /app/.env.* .
3742
COPY --from=builder /app/wait-for-it.sh .
3843

3944
# Expose the port that your application will run on
4045
EXPOSE 8080
4146

47+
# Script to dynamically generate .env.docker at runtime
48+
COPY generate-env.sh /docker-entrypoint.d/generate-env.sh
49+
RUN chmod +x /docker-entrypoint.d/generate-env.sh
50+
51+
# Copy the custom entrypoint
52+
COPY entrypoint.sh /entrypoint.sh
53+
RUN chmod +x /entrypoint.sh
54+
55+
# Set the custom entrypoint
56+
ENTRYPOINT ["/entrypoint.sh"]
57+
4258
# Command to run your application
4359
CMD ["./cadangan-public-api", "-env", "$GO_ENV"]

0 commit comments

Comments
 (0)