-
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.
Merge pull request #43 from Spacelocust/feature/deploy-api
Feat / config deploy api
- Loading branch information
Showing
12 changed files
with
167 additions
and
8 deletions.
There are no files selected for viewing
Empty 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
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,57 @@ | ||
name: Publish API | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Linting API, Testing API] | ||
types: [completed] | ||
branches: ["main"] | ||
|
||
push: | ||
branches: | ||
- main | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-and-push-api: | ||
name: Push Docker image API | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: docker/prod/golang/Dockerfile | ||
builder: ${{ steps.buildx.outputs.name }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: spacelocust/fd-api:latest | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,54 @@ | ||
name: Publish Migrations | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "api/migrations/**" | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-and-push-migrations: | ||
name: Push Docker image Migrations | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: docker/prod/atlas/Dockerfile | ||
builder: ${{ steps.buildx.outputs.name }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: spacelocust/fd-migrations:latest | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
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,3 @@ | ||
FROM arigaio/atlas:latest | ||
|
||
COPY migrations /migrations |
Empty 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,10 @@ | ||
FROM alpine:3.20 | ||
|
||
COPY --from=arigaio/atlas:latest atlas /usr/bin/atlas | ||
|
||
COPY ./api/migrations /migrations | ||
|
||
# Use SHELL to explicitly execute the command with shell (e.g. https://docs.docker.com/reference/build-checks/json-args-recommended/) | ||
SHELL ["/bin/sh", "-c"] | ||
|
||
ENTRYPOINT atlas migrate apply --dir file://migrations --url $DATABASE_URL |
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 @@ | ||
{ | ||
email {$ACME_EMAIL} | ||
admin off | ||
} | ||
|
||
api.yam-yam.dev { | ||
reverse_proxy * api:5000 | ||
} |
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,28 @@ | ||
FROM golang:1.22-alpine AS builder | ||
|
||
WORKDIR /go/src/app | ||
|
||
COPY /api/go.* ./ | ||
|
||
# Install dependencies | ||
RUN go mod download &&\ | ||
go mod verify | ||
|
||
COPY /api . | ||
|
||
# Remove the migrations folder and build the binary | ||
RUN rm -rf /migrations && GOOS=linux GOARCH=amd64 go build -o fd-democracy main.go | ||
|
||
FROM debian:buster-slim AS runner | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the binary from the builder stage | ||
COPY --from=builder /go/src/app/fd-democracy /go/bin/fd-democracy | ||
|
||
ENV PATH="/go/bin:${PATH}" | ||
|
||
ENTRYPOINT ["fd-democracy", "gin-server"] |