-
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.
misc(ci/cd): Initial Docker & Github Action setup
- Loading branch information
Showing
4 changed files
with
138 additions
and
1 deletion.
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,60 @@ | ||
name: Build xyzuan-be Development Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
# pull_request: | ||
# branches: | ||
# - main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# - name: Log in to Docker Hub | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build \ | ||
--build-arg PORT=3121 \ | ||
--build-arg NODE_ENV=dev \ | ||
--build-arg DOMAIN=xyzuan.my.id \ | ||
--build-arg PASSWORD_PEPPER=${{ secrets.PASSWORD_PEPPER }} \ | ||
--build-arg DATABASE_URL=${{ secrets.DATABASE_URL }} \ | ||
--build-arg GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} \ | ||
--build-arg GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} \ | ||
--build-arg GITHUB_CLIENT_ID=${{ secrets.GITHUB_CLIENT_ID }} \ | ||
--build-arg GITHUB_CLIENT_SECRET=${{ secrets.GITHUB_CLIENT_SECRET }} \ | ||
--build-arg LINKEDIN_CLIENT_ID=${{ secrets.LINKEDIN_CLIENT_ID }} \ | ||
--build-arg LINKEDIN_CLIENT_SECRET=${{ secrets.LINKEDIN_CLIENT_SECRET }} \ | ||
--build-arg TELEGRAM_TOKEN=${{ secrets.TELEGRAM_TOKEN }} \ | ||
--build-arg TELEGRAM_CHAT_ID=${{ secrets.TELEGRAM_CHAT_ID }} \ | ||
--build-arg CLOUDINARY_CLOUD_NAME=${{ secrets.CLOUDINARY_CLOUD_NAME }} \ | ||
--build-arg CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} \ | ||
--build-arg CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} \ | ||
-t xyzuan_be:latest -f misc/Dockerfile.dev . | ||
- name: Tag Docker image | ||
run: | | ||
IMAGE_NAME=xyzuan_be | ||
GIT_SHA=$(echo "${{ github.sha }}" | head -c 7) | ||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$GIT_SHA | ||
# - name: Push Docker image | ||
# run: | | ||
# IMAGE_NAME=xyzuan_be | ||
# GIT_SHA=$(echo "${{ github.sha }}" | head -c 7) | ||
# docker push $IMAGE_NAME:latest | ||
# docker push $IMAGE_NAME:$GIT_SHA |
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 |
---|---|---|
|
@@ -40,4 +40,6 @@ yarn-error.log* | |
**/*.tgz | ||
**/*.log | ||
package-lock.json | ||
**/*.bun | ||
**/*.bun | ||
|
||
misc/Dockerfile.local |
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,73 @@ | ||
FROM oven/bun AS build | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json bun.lockb tsconfig.json ./ | ||
RUN \ | ||
if [ -f bun.lockb ]; then bun install --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
COPY ./src ./src | ||
COPY ./prisma ./prisma | ||
|
||
RUN bun install | ||
RUN bunx prisma generate | ||
RUN bun build \ | ||
--compile \ | ||
--minify-whitespace \ | ||
--minify-syntax \ | ||
--target bun \ | ||
--outfile server \ | ||
./src/index.ts | ||
|
||
FROM gcr.io/distroless/cc | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app/server server | ||
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma | ||
COPY --from=build /app/node_modules/@prisma /app/node_modules/@prisma | ||
|
||
ARG PORT | ||
ARG NODE_ENV | ||
ARG DOMAIN | ||
ARG PASSWORD_PEPPER | ||
ARG DATABASE_URL | ||
|
||
ARG GOOGLE_CLIENT_ID | ||
ARG GOOGLE_CLIENT_SECRET | ||
ARG GITHUB_CLIENT_ID | ||
ARG GITHUB_CLIENT_SECRET | ||
ARG LINKEDIN_CLIENT_ID | ||
ARG LINKEDIN_CLIENT_SECRET | ||
ARG TELEGRAM_TOKEN | ||
ARG TELEGRAM_CHAT_ID | ||
|
||
ARG CLOUDINARY_CLOUD_NAME | ||
ARG CLOUDINARY_API_KEY | ||
ARG CLOUDINARY_API_SECRET | ||
|
||
ENV PORT=$PORT | ||
ENV NODE_ENV=$NODE_ENV | ||
ENV DOMAIN=$DOMAIN | ||
ENV PASSWORD_PEPPER=$PASSWORD_PEPPER | ||
ENV DATABASE_URL=$DATABASE_URL | ||
|
||
ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID | ||
ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET | ||
ENV GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID | ||
ENV GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET | ||
ENV LINKEDIN_CLIENT_ID=$LINKEDIN_CLIENT_ID | ||
ENV LINKEDIN_CLIENT_SECRET=$LINKEDIN_CLIENT_SECRET | ||
ENV TELEGRAM_TOKEN=$TELEGRAM_TOKEN | ||
ENV TELEGRAM_CHAT_ID=$TELEGRAM_CHAT_ID | ||
|
||
ENV CLOUDINARY_CLOUD_NAME=$CLOUDINARY_CLOUD_NAME | ||
ENV CLOUDINARY_API_KEY=$CLOUDINARY_API_KEY | ||
ENV CLOUDINARY_API_SECRET=$CLOUDINARY_API_SECRET | ||
|
||
EXPOSE 3121 | ||
|
||
CMD ["./server"] | ||
|
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