diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..69b1581 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,39 @@ +name: Build and Deploy to AWS ECR + +on: + push: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Update submodules + run: git submodule update --init --recursive + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: true + + - name: Build, Tag, and Push Docker image to ECR + run: | + docker build -t clearsettleengineadmin . + docker tag clearsettleengineadmin 211125762589.dkr.ecr.us-west-2.amazonaws.com/repo:clearsettleengineadmin + docker push 211125762589.dkr.ecr.us-west-2.amazonaws.com/repo:clearsettleengineadmin + env: + AWS_DEFAULT_REGION: us-west-2 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..af9bff1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Use an official Elixir runtime as a parent image +FROM elixir:latest + +# Create and set the working directory +WORKDIR /app + +# Copy the mix.exs and mix.lock files to the container +COPY mix.exs mix.lock ./ + +# Install hex and rebar + +RUN mix archive.install github hexpm/hex branch latest --force + +RUN mix local.rebar --force +# Install dependencies +RUN mix deps.get + +# Copy the rest of your application's code +COPY . . + +# Compile the project + +RUN mix do compile + +# Run the application +CMD ["mix", "run"] diff --git a/config/config.exs b/config/config.exs index 7f33a1f..5997b51 100644 --- a/config/config.exs +++ b/config/config.exs @@ -25,6 +25,16 @@ config :clear_settle_engine_admin, ClearSettleEngineAdminWeb.Endpoint, pubsub_server: ClearSettleEngineAdmin.PubSub, live_view: [signing_salt: "kLC5F5Sh"] +config :clear_settle_engine, ClearSettleEngine.Repo, + username: System.get_env("DB_USERNAME", "postgres"), + password: System.get_env("DB_PASSWORD", ""), + database: System.get_env("DB_DATABASE", "clear_settle_engine_dev"), + hostname: System.get_env("DB_HOST", "localhost"), + port: System.get_env("DB_PORT", "5432"), + ssl: true, + ssl_opts: [verify: :verify_none], + pool_size: String.to_integer(System.get_env("DB_POOL_SIZE", "10")) + # Configures the mailer # # By default it uses the "Local" adapter which stores the emails diff --git a/config/dev.exs b/config/dev.exs index 4ab1744..7ac2b7c 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,14 +1,14 @@ import Config # Configure your database -config :clear_settle_engine_admin, ClearSettleEngineAdmin.Repo, - username: "postgres", - password: "", - hostname: "localhost", - database: "clear_settle_engine_dev", - stacktrace: true, - show_sensitive_data_on_connection_error: true, - pool_size: 10 +# config :clear_settle_engine_admin, ClearSettleEngineAdmin.Repo, +# username: "postgres", +# password: "", +# hostname: "localhost", +# database: "clear_settle_engine_dev", +# stacktrace: true, +# show_sensitive_data_on_connection_error: true, +# pool_size: 10 # For development, we disable any cache and enable # debugging and code reloading.