-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
35 lines (30 loc) · 1.06 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
version: 0.2
env:
parameter-store:
DOCKER_REGISTRY_USERNAME: /my-app/docker-credentials/username
DOCKER_REGISTRY_PASSWORD: /my-app/docker-credentials/password
DOCKER_REGISTRY_URL: /my-app/docker-credentials/URL
ENVIRONMENT_VAR_1: /my-app/environment-var-1
ENVIRONMENT_VAR_2: /my-app/environment-var-2
phases:
install:
runtime-versions:
golang: 1.21
pre_build:
commands:
- echo "Installing dependencies."
- go mod download
- echo "Creating .env file"
- echo "$ENVIRONMENT_VAR_1" > .env
- echo "$ENVIRONMENT_VAR_2" >> .env
- echo ".env file created"
build:
commands:
- echo "Building docker image."
- cd .
- echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
- docker build -t "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/weather-app:latest" .
- docker push "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/weather-app:latest"
post_build:
commands:
- echo "Build completed successfully"