Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ jobs:
PR=$(echo "$GITHUB_REF" | awk -F / '{print $3}')
echo "$PR"
echo "pr_number=pr-$PR" >> $GITHUB_ENV
# Build the Docker image
- name: Build Docker Image
- name: Set up Docker Buildx
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]'
run: |
make build
docker build -t "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":${{ env.pr_number }} .
- name: Push dev image
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Build and Push Docker Image
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]'
run: |
docker push "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":${{ env.pr_number }}
docker buildx build --platform linux/amd64,linux/arm64 \
-t "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":${{ env.pr_number }} \
--push .
- name: template helm
if: github.actor != 'dependabot[bot]'
run: |
Expand Down Expand Up @@ -168,15 +167,16 @@ jobs:
mv $IMAGE-${{ env.HELM_VERSION }}.tgz $IMAGE-${{ env.pr_number }}.tgz
gsutil cp $IMAGE-*.tgz gs://$ARTIFACT_BUCKET/$IMAGE/

- name: Build Release Image
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main'
run: |
docker build -t "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":latest -t "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":${{ env.version }} .
- name: Push Release image
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Build and Push Docker Image
if: github.ref == 'refs/heads/main'
run: |
docker push "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":${{ env.version }}
docker push "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":latest
docker buildx build --platform linux/amd64,linux/arm64 \
-t "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":latest \
-t "$REGISTRY_HOSTNAME"/"$GAR_GOOGLE_PROJECT_ID"/"$GAR_REPOSITORY"/"$IMAGE":${{ env.version }} \
--push .

- name: Publish Charts
if: github.ref == 'refs/heads/main'
Expand Down
26 changes: 18 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
FROM golang:1.19.3-alpine3.16

EXPOSE 8080
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS build-stage

RUN mkdir "/src"
WORKDIR "/src"

COPY . .

COPY build/linux-amd64/bin/main /usr/local/bin/
RUN go build -v -o main
RUN chmod 755 main

FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS final-stage

RUN addgroup -S survey-group && adduser -S survey-user -G survey-group
RUN mkdir -p "/opt/survey"
RUN chown survey-user:survey-group /opt/survey

WORKDIR "/opt/survey"
COPY --from=build-stage /src/main .
COPY --from=build-stage /src/db-migrations /db-migrations

COPY db-migrations /db-migrations
RUN chmod 550 /opt/survey/main
RUN chown survey-user:survey-group /opt/survey/main
RUN chown survey-user:survey-group /db-migrations

RUN go build
RUN ls
USER survey-user

CMD "./rm-survey-service"
CMD "./main"
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ test:
# Run integration and unit tests with the service running in docker.
# Builds a docker image, starts it up with a postgres container, waits for a successful response from the survey service
# /info endpoint, then runs unit tests and integration tests against the services in docker.
integration-test: docker
docker compose -f compose-integration-tests.yml down
docker compose -f compose-integration-tests.yml up -d
integration-test: build
docker build . -t europe-west2-docker.pkg.dev/ons-ci-rmrasbs/images/survey:integration-test
docker compose -f docker-compose.yml down
TAG=integration-test docker compose -f docker-compose.yml up -d
./wait_for_startup_integration_tests.sh ||\
(docker compose -f compose-integration-tests.yml down && exit 1)
(docker compose -f docker-compose.yml down && exit 1)
go test --tags=integration -race -coverprofile=coverage.txt -covermode=atomic github.com/ONSdigital/rm-survey-service/models ||\
(docker compose -f compose-integration-tests.yml down && exit 1)
docker compose -f compose-integration-tests.yml down
(docker compose -f docker-compose.yml down && exit 1)
docker compose -f docker-compose.yml down

# Remove the build directory tree.
clean:
if [ -d $(BUILD) ]; then rm -r $(BUILD); fi;

docker: build
docker build . -t europe-west2-docker.pkg.dev/ons-ci-rmrasbs/images

docker build . -t europe-west2-docker.pkg.dev/ons-ci-rmrasbs/images/survey
4 changes: 2 additions & 2 deletions _infra/helm/survey/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 11.0.66
version: 11.0.67

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 11.0.66
appVersion: 11.0.67
22 changes: 0 additions & 22 deletions compose-integration-tests.yml

This file was deleted.

8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
database:
container_name: postgres
image: postgres:9.6-alpine
image: postgres:14
ports:
- "5432:5432"
environment:
Expand All @@ -11,12 +11,10 @@ services:

survey:
container_name: surveysvc
image: europe-west2-docker.pkg.dev/ons-ci-rmrasbs/images/survey
image: europe-west2-docker.pkg.dev/ons-ci-rmrasbs/images/survey:${TAG:-latest}
ports:
- "8080:8080"
links:
- database
environment:
- DATABASE_URL=postgres://postgres:password@database/postgres?sslmode=disable
- DATABASE_URL=postgres://postgres:password@database:5432/postgres?sslmode=disable
- security_user_name=admin
- security_user_password=secret
52 changes: 32 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
module github.com/ONSdigital/rm-survey-service

go 1.24
go 1.25

require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/blendle/zapdriver v1.3.1
github.com/gofrs/uuid v4.2.0+incompatible
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/lib/pq v1.10.6
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang-migrate/migrate/v4 v4.19.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/lib/pq v1.10.9
github.com/pkg/errors v0.9.1
github.com/smartystreets/goconvey v1.7.2
go.uber.org/zap v1.21.0
github.com/smartystreets/goconvey v1.8.1
go.uber.org/zap v1.27.0
gopkg.in/go-playground/validator.v9 v9.31.0
)

require (
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github/v39 v39.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20211216084454-9ae78a3fa6dd // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/smarty/assertions v1.16.0 // indirect
github.com/smartystreets/assertions v1.2.1 // indirect
github.com/tools/godep v0.0.0-20180126220526-ce0bfadeb516 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/tools v0.37.0 // indirect
golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
)
Loading
Loading