Skip to content

Commit

Permalink
Switch prod build to official with multi-stage
Browse files Browse the repository at this point in the history
Use aliases for copy statement (compat change)

Install missing dependencies to runner

Fixed typo
  • Loading branch information
megakoresh committed Feb 9, 2020
1 parent 3d954ce commit c42c083
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ tasks:
- go install github.com/haya14busa/goverage
- go install github.com/snikch/goodman/cmd/goodman
- go install github.com/go-swagger/go-swagger/cmd/swagger
- '{{ if ne OS "windows" }} bash -c "curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C $(go env GOPATH)/bin goreleaser"{{ else }} {{ end }}'
- '{{ if ne OS "windows" }} sh -c "curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C $(go env GOPATH)/bin goreleaser"{{ else }} {{ end }}'
- '{{ if ne OS "windows" }} chmod +x $(go env GOPATH)/bin/goreleaser{{ else }} {{ end }}'
- '{{ if eq OS "windows" }} echo "NOTICE: You must download goreleaser manually to build this application https://github.com/goreleaser/goreleaser/releases "{{ else }}:{{ end }}'
- '{{ if ne OS "windows" }} bash -c "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v{{ .GOLINTER_VERSION }}"{{ else }}{{ end }}'
- '{{ if ne OS "windows" }} sh -c "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v{{ .GOLINTER_VERSION }}"{{ else }}{{ end }}'
- '{{ if eq OS "windows" }} echo "NOTICE: You need to install golangci-lint manually to build this application https://github.com/golangci/golangci-lint#install"{{ else }}{{ end }}'

compile:
Expand Down
1 change: 0 additions & 1 deletion deployment/docker/ci/bin/install
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash


echo "--> Turn off StrictKeyChecking"
cat > /etc/ssh/ssh_config <<EOF
Host *
Expand Down
28 changes: 16 additions & 12 deletions deployment/docker/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# ansible-semaphore production image
#
# Uses frolvlad alpine so we have access to glibc which is needed for golang
# and when deploying in openshift
FROM frolvlad/alpine-glibc:alpine-3.7
FROM golang:1.13-alpine3.10 as builder

LABEL maintainer="Tom Whiston <tom.whiston@gmail.com>"

RUN apk add --no-cache git ansible mysql-client curl openssh-client tini && \
COPY ./ /go/src/github.com/ansible-semaphore/semaphore
WORKDIR /go/src/github.com/ansible-semaphore/semaphore

RUN apk add --no-cache -U libc-dev curl nodejs npm git && \
./deployment/docker/prod/bin/install

# Uses frolvlad alpine so we have access to glibc which is needed for golang
# and when deploying in openshift
FROM frolvlad/alpine-glibc:alpine-3.10 as runner

RUN apk add --no-cache git curl ansible mysql-client openssh-client tini && \
adduser -D -u 1001 -G root semaphore && \
mkdir -p /tmp/semaphore && \
mkdir -p /etc/semaphore && \
chown -R semaphore:0 /tmp/semaphore && \
chown -R semaphore:0 /etc/semaphore

COPY ./ /go/src/github.com/ansible-semaphore/semaphore
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
COPY --from=builder /usr/local/bin/semaphore-wrapper /usr/local/bin/
COPY --from=builder /usr/local/bin/semaphore /usr/local/bin/

RUN apk add --no-cache -U libc-dev go nodejs && \
./deployment/docker/prod/bin/install && \
apk del libc-dev go nodejs && \
rm -rf /go/* && \
rm -rf /var/cache/apk/*
RUN chown -R semaphore:0 /usr/local/bin/semaphore-wrapper &&\
chown -R semaphore:0 /usr/local/bin/semaphore

WORKDIR /home/semaphore
USER 1001
Expand Down
6 changes: 0 additions & 6 deletions deployment/docker/prod/bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

set -e

# Go build environment
export GOROOT=/usr/lib/go
export GOPATH=/go
export GOBIN=/go/bin
export PATH="${PATH}:${GOBIN}"

# Get prerequisites for building the app
(cd $(go env GOPATH) && curl -sL https://taskfile.dev/install.sh | sh)

Expand Down

0 comments on commit c42c083

Please sign in to comment.