-
Notifications
You must be signed in to change notification settings - Fork 3
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 #30 from gilmaimon/rewrite-backend
Rewrite backend
- Loading branch information
Showing
56 changed files
with
17,485 additions
and
17,606 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,39 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' # Triggers on push to any branch | ||
pull_request: | ||
branches: | ||
- master # Triggers on PR to master branch | ||
workflow_dispatch: # Manually trigger the workflow | ||
|
||
jobs: | ||
build: | ||
if: github.ref != 'refs/heads/master' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build -t server . | ||
|
||
deploy: | ||
needs: build # Ensure deploy job waits for build job | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/master' | ||
steps: | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Push Docker image | ||
run: docker push server:latest |
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,58 @@ | ||
# Stage 1: Build React App | ||
FROM node:22-alpine AS frontend-builder | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the React app source code | ||
COPY client/package.json client/package-lock.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the React app source code | ||
COPY client/src/ /app/src | ||
COPY client/public/ /app/public | ||
|
||
RUN npm run build | ||
|
||
# Stage 2: Build the Go binary | ||
FROM golang:1.20-alpine AS builder | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy go.mod and go.sum files | ||
COPY server-v2/go.mod server-v2/go.sum ./ | ||
|
||
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed | ||
RUN go mod download | ||
|
||
# Copy the source code into the container | ||
COPY server-v2 ./ | ||
|
||
# Build the Go app | ||
RUN go build -o server . | ||
|
||
# Stage 3: Run the Go binary | ||
FROM alpine:latest | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /root/ | ||
|
||
# Copy configuration and assets | ||
COPY config-prod.yaml ./server.yaml | ||
COPY server-v2/Verdana.ttf ./ | ||
|
||
# Copy the static content | ||
COPY --from=frontend-builder /app/build/ /app/static/ | ||
|
||
# Copy the Pre-built binary file from the previous stage | ||
COPY --from=builder /app/server . | ||
|
||
# Expose http ports to the outside world | ||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
# Command to run the executable | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set -ex | ||
|
||
docker build -t server . | ||
|
||
docker run -p 80:80 \ | ||
-p 443:443 \ | ||
-v ./cert.pem:/certs/ardu-badge.cert \ | ||
-v ./privkey.pem:/certs/ardu-badge.key \ | ||
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
Oops, something went wrong.