Skip to content

Commit

Permalink
Merge pull request #118 from ContainerMaintainers/development
Browse files Browse the repository at this point in the history
.env fix added
  • Loading branch information
adamjhr authored Apr 25, 2023
2 parents f449a9d + 94169f9 commit 8c711c9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 62 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/Continuous-Deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,11 @@ jobs:
tags: ${{ secrets.DOCKER_USERNAME }}/minitwit:latest
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/minitwit:webbuildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/minitwit:webbuildcache,mode=max
build-args: |
db_name=${{ secrets.DB_NAME }}
db_port=${{ secrets.DB_PORT }}
db_password=${{ secrets.DB_PASSWORD }}
db_user=${{ secrets.DB_USER }}
db_host=${{ secrets.DB_HOST }}
session_key=${{ secrets.SESSION_KEY }}
port=${{ vars.PORT }}
gin_mode=${{ vars.GIN_MODE }}

- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: bash deploy.sh containermaintainers ${{ vars.PORT }}
script: bash deploy.sh containermaintainers ${{ vars.PORT }} ${{ secrets.DB_NAME }} ${{ secrets.DB_PORT }} ${{ secrets.DB_PASSWORD }} ${{ secrets.DB_USER }} ${{ secrets.DB_HOST }} ${{ secrets.SESSION_KEY }} ${{ vars.GIN_MODE }}
8 changes: 0 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ WORKDIR /usr/src/app
# Copy everything
COPY . .

RUN sed -i 's/\r$//' env_file.sh

# Give permissions to run env_file.sh
RUN chmod +x env_file.sh

# Create .env if it doesn't exist
RUN sh env_file.sh ${db_user} ${db_password} ${db_name} ${db_port} ${db_host} ${port} ${session_key} ${gin_mode}

# Download Go modules
RUN go mod download && go mod tidy

Expand Down
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ docker pull $1/minitwit:latest
echo "Stopping current minitwit"
docker stop minitwit
echo "Deploying $DOCKER_USERNAME/minitwit:latest to $PORT"
docker run --rm -d -p $2:$2 --name minitwit $1/minitwit:latest
docker run -d -p $2:$2 --name minitwit $1/minitwit:latest --env DB_NAME=$3 --env DB_USER=$6 --env DB_PASSWORD=$5 --env DB_HOST=$7 --env DB_PORT=$4 --env PORT=$2
17 changes: 9 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ services:
context: .
dockerfile: Dockerfile
args:
db_user: ${DB_USER}
db_password: ${DB_PASSWORD}
db_host: ${DB_HOST}
db_name: ${DB_NAME}
db_port: ${DB_PORT}
port: ${PORT}
session_key: ${SESSION_KEY}
gin_mode: ${GIN_MODE}
BUILDKIT_PROGRESS: plain docker-compose build
ports:
- '8080:8080'
environment:
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_HOST=${DB_HOST}
- DB_NAME=${DB_NAME}
- DB_PORT=${DB_PORT}
- PORT=${PORT}
- SESSION_KEY=${SESSION_KEY}
- GIN_MODE=${GIN_MODE}
restart: always
links:
- postgres:database
Expand Down
16 changes: 0 additions & 16 deletions env_file.sh

This file was deleted.

14 changes: 0 additions & 14 deletions initializers/envVars.go

This file was deleted.

5 changes: 0 additions & 5 deletions minitwit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/ContainerMaintainers/MiniTwit-Golang/controllers"
"github.com/ContainerMaintainers/MiniTwit-Golang/database"
"github.com/ContainerMaintainers/MiniTwit-Golang/initializers"
"github.com/ContainerMaintainers/MiniTwit-Golang/monitoring"
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -18,10 +17,6 @@ var (
user = -1
)

func init() {
initializers.LoadEnvVars()
}

func metricsHandler() gin.HandlerFunc {
reg := prometheus.NewRegistry()
monitoring.NewMetrics(reg)
Expand Down

0 comments on commit 8c711c9

Please sign in to comment.